public class LayerImpl extends Object implements ILayer
Modifier and Type | Field and Description |
---|---|
static Pattern |
GZIPFLAG_KEY_PATTERN |
protected static List<ICacheKeyGenerator> |
s_layerCacheKeyGenerators |
BUILDFUTURESQUEUE_REQATTRNAME, DEPENDENT_FEATURES, NOCACHE_RESPONSE_REQATTRNAME, SOURCEMAP_RESOURCE_PATH, SOURCEMAP_RESOURCE_PATHCOMP
Modifier and Type | Method and Description |
---|---|
protected void |
addCacheKeyGenerators(Map<String,ICacheKeyGenerator> cacheKeyGenerators,
Iterable<ICacheKeyGenerator> gens)
Adds the cache key generators specified in
gens to the map of
classname/key-generator pairs, combining key-generators as needed. |
protected boolean |
cacheEntryEvicted(com.ibm.jaggr.core.impl.layer.CacheEntry cacheEntry)
Called by the layer cache manager when a layer build is evicted from the
eviction map do to size limitations.
|
protected String |
generateCacheKey(javax.servlet.http.HttpServletRequest request,
Map<String,ICacheKeyGenerator> cacheKeyGenerators)
Generates a cache key for the layer.
|
protected List<ICacheKeyGenerator> |
getCacheKeyGenerators(List<ModuleBuildFuture> futures) |
InputStream |
getInputStream(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Returns the
InputStream for the assembled and gzipped layer build
which was generated using the compilation level, has-conditions and
options that are specified in the request. |
String |
getKey()
Returns the cache key that this layer is associated with in the
layer cache.
|
long |
getLastModified(javax.servlet.http.HttpServletRequest request)
Returns the lastModified time of the layer based on the latest last
modified time of each of the component source files.
|
protected long |
getLastModified(IAggregator aggregator,
com.ibm.jaggr.core.impl.layer.ModuleList modules)
Returns the newest last modified time of the files in the list
|
protected com.ibm.jaggr.core.impl.layer.ModuleList |
getModules(javax.servlet.http.HttpServletRequest request)
Unfolds a folded module list and returns a list of Source objects
|
static ILayerCache |
newLayerCache(IAggregator aggregator)
Static factory method for layer cache objects
|
protected IModule |
newModule(javax.servlet.http.HttpServletRequest request,
String mid) |
void |
setReportCacheInfo(boolean isReportCacheInfo) |
protected InputStream |
setResponse(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
com.ibm.jaggr.core.impl.layer.CacheEntry entry)
Sets the response data in the response object and calls
setResponseHeaders(HttpServletRequest, HttpServletResponse, int) to set the headers. |
protected void |
setResponseHeaders(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
int size) |
String |
toString()
Calls the filtered version with a null filter
|
protected InputStream |
trySetResponse(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
com.ibm.jaggr.core.impl.layer.CacheEntry entry)
Like
setResponse(HttpServletRequest, HttpServletResponse, CacheEntry) , but
returns null instead of throwing an exception if the cache data is not available. |
protected static final List<ICacheKeyGenerator> s_layerCacheKeyGenerators
public static final Pattern GZIPFLAG_KEY_PATTERN
public LayerImpl(String cacheKey, int id)
cacheKey
- The folded module list as specified in the requestid
- unique identifierpublic String getKey()
ILayer
public void setReportCacheInfo(boolean isReportCacheInfo)
isReportCacheInfo
- public InputStream getInputStream(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
ILayer
InputStream
for the assembled and gzipped layer build
which was generated using the compilation level, has-conditions and
options that are specified in the request.
Has the side effect of setting the appropriate Content-Length, Content-Type and Content-Encoding headers in the response.
getInputStream
in interface ILayer
request
- The request objectresponse
- The response objectIOException
protected InputStream setResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.ibm.jaggr.core.impl.layer.CacheEntry entry) throws IOException
setResponseHeaders(HttpServletRequest, HttpServletResponse, int)
to set the headers.request
- The servlet request objectresponse
- The servlet response objectentry
- The CacheEntry
object containing the response data.IOException
protected InputStream trySetResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.ibm.jaggr.core.impl.layer.CacheEntry entry) throws IOException
setResponse(HttpServletRequest, HttpServletResponse, CacheEntry)
, but
returns null instead of throwing an exception if the cache data is not available.request
- The servlet request objectresponse
- The servlet response objectentry
- The CacheEntry
object containing the response data.IOException
protected void addCacheKeyGenerators(Map<String,ICacheKeyGenerator> cacheKeyGenerators, Iterable<ICacheKeyGenerator> gens)
gens
to the map of
classname/key-generator pairs, combining key-generators as needed.cacheKeyGenerators
- Map of classname/key-generator pairs to add to.gens
- the cache key generators to add.protected String generateCacheKey(javax.servlet.http.HttpServletRequest request, Map<String,ICacheKeyGenerator> cacheKeyGenerators) throws IOException
request
- the request objectcacheKeyGenerators
- map of cache key generator class names to instance objectsIOException
public long getLastModified(javax.servlet.http.HttpServletRequest request) throws IOException
ILayer
In production mode, the last modified times of the source files are checked when the layer is initially created and the first time the layer is accessed after a server restart. In development mode, we determine the last modified time of the layer from the last modified times of the component source files on every request.
getLastModified
in interface ILayer
request
- The http request objectIOException
public String toString()
protected com.ibm.jaggr.core.impl.layer.ModuleList getModules(javax.servlet.http.HttpServletRequest request) throws IOException
request
- The requestIOException
protected long getLastModified(IAggregator aggregator, com.ibm.jaggr.core.impl.layer.ModuleList modules)
aggregator
- modules
- The list of ModuleFile objectsprotected List<ICacheKeyGenerator> getCacheKeyGenerators(List<ModuleBuildFuture> futures) throws IOException
IOException
protected boolean cacheEntryEvicted(com.ibm.jaggr.core.impl.layer.CacheEntry cacheEntry)
cacheEntry
- The cache entry that was evictedpublic static ILayerCache newLayerCache(IAggregator aggregator)
aggregator
- the aggregator this layer cache belongs toprotected void setResponseHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int size)
Copyright © 2011-2015 IBM. All Rights Reserved.