public class ModuleImpl extends ModuleIdentifier implements IModule
Modifier and Type | Class and Description |
---|---|
protected static class |
ModuleImpl.SerializationProxy |
Modifier | Constructor and Description |
---|---|
protected |
ModuleImpl(ModuleImpl module)
Copy constructor.
|
|
ModuleImpl(String mid,
URI uri)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
clearCached(ICacheManager mgr)
Asynchronously delete the set of cached files for this module.
|
Future<ModuleBuildReader> |
getBuild(javax.servlet.http.HttpServletRequest request)
Returns the compiled (minified, has-filtered) output for this JavaScript
module.
|
protected Future<ModuleBuildReader> |
getBuild(javax.servlet.http.HttpServletRequest request,
boolean fromCacheOnly)
Adds
fromCacheOnly param that is used by unit test cases. |
protected String |
getCachedFileName(String key) |
protected List<ICacheKeyGenerator> |
getCacheKeyGenerators() |
protected Collection<String> |
getKeys() |
IResource |
getResource(IAggregator aggregator)
This method is provided so that the module can function as a runtime cache
for the
IResource object associated with the module URI that was
used to construct this instance. |
URI |
getURI()
Returns the source url for this module
|
static IModuleCache |
newModuleCache(IAggregator aggregator)
Static factory method for a new module cache object
|
void |
processExtraModules(ModuleBuildReader reader,
javax.servlet.http.HttpServletRequest request,
com.ibm.jaggr.core.impl.module.ModuleImpl.CacheEntry cacheEntry)
For any extra modules specified by
cacheEntry , obtain a build
future from the module cache manager and add it to the ModuleBuildReader
specified by reader . |
String |
toString() |
protected Object |
writeReplace() |
clone, getModuleId, getModuleName, getPluginName
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getModuleId, getModuleName, getPluginName
public ModuleImpl(String mid, URI uri)
mid
- the module iduri
- the module URI
protected ModuleImpl(ModuleImpl module)
module
- public URI getURI()
IModule
public IResource getResource(IAggregator aggregator)
IModule
IResource
object associated with the module URI that was
used to construct this instance.
Note that instances of IModule
are both Serializable
and Cloneable, yet instances of IResource
are neither, so the module
must not attempt to save the cached IResource
object to its
persistent state, nor to object clones.
getResource
in interface IModule
aggregator
- the aggregator. The module may use the IAggregator.newResource(URI)
method to obtain a new instance of the IResource
.IResource
object for this module's URI.public Future<ModuleBuildReader> getBuild(javax.servlet.http.HttpServletRequest request) throws IOException
This function returns a Future
<
ModuleBuildReader
>
which can be used to obtain a reference to the
ModuleBuildReader
when it is available. If the minified version of
this module with the requested compilation level and has-filtering
conditions already exists in the cache, then a completed Future
will be returned. If the module needs to be compiled, then the
compilation will be performed by an asynchronous thread and a
Future
will be returned which can be used to access the
ModuleBuildReader
when it is available.
The caller of this function is responsible for closing the reader associated with the build object.
getBuild
in interface IModule
request
- The http servlet request objectFuture
<
ModuleBuildReader
>
that can
be used to obtain a reader to the minified output.IOException
UnsupportedOperationException
- if no resource factory or module builder can be found for this resource.protected Future<ModuleBuildReader> getBuild(javax.servlet.http.HttpServletRequest request, boolean fromCacheOnly) throws IOException
fromCacheOnly
param that is used by unit test cases. Do
not call this method directly from production code. Use
getBuild(HttpServletRequest)
instead.request
- The http servlet request objectfromCacheOnly
- If true, an exception is thrown if the the requested module
cannot be returned from cache. Used by unit tests.Future
<
ModuleBuildReader
>
that can
be used to obtain a reader to the minified output.IOException
UnsupportedOperationException
- if no resource factory or module builder can be found for this resource.public void processExtraModules(ModuleBuildReader reader, javax.servlet.http.HttpServletRequest request, com.ibm.jaggr.core.impl.module.ModuleImpl.CacheEntry cacheEntry) throws IOException
cacheEntry
, obtain a build
future from the module cache manager and add it to the ModuleBuildReader
specified by reader
.reader
- the ModuleBuildReader
to add the extra modules torequest
- The http requestcacheEntry
- The cache entry object for the current moduleIOException
protected String getCachedFileName(String key) throws InterruptedException
InterruptedException
protected Collection<String> getKeys()
protected List<ICacheKeyGenerator> getCacheKeyGenerators()
public void clearCached(ICacheManager mgr)
clearCached
in interface IModule
mgr
- The cache manager. Modules can use
ICacheManager.deleteFileDelayed(String)
to
asynchronously schedule cache files for deletion following a
delay period, avoiding the potential for synchronization
issues associated with the use of cache files by multiple
threads.public static IModuleCache newModuleCache(IAggregator aggregator)
aggregator
- the aggregator that this module cache belongs toprotected Object writeReplace() throws ObjectStreamException
ObjectStreamException
Copyright © 2011-2015 IBM. All Rights Reserved.