public interface IAggregator
HttpServlet
, so they are created by the framework when a servlet
implementing this interface is instanciated.
The aggregator registers as an OSGi service using this interface and the
servlet alias as the name
service property.
When servicing requests, a reference to the aggregator may be obtained from
the request attribute named AGGREGATOR_REQATTRNAME
. It may also be
obtained from the session context attributes using the same name.
Modifier and Type | Interface and Description |
---|---|
static interface |
IAggregator.SubstitutionTransformer
Transformer interface used by
substituteProps(String, SubstitutionTransformer) . |
Modifier and Type | Field and Description |
---|---|
static String |
AGGREGATOR_REQATTRNAME
HTTP request attribute name for the
IAggregator instance
associated with a given request |
static String |
CONCURRENTMAP_REQATTRNAME
Name of the request attribute which holds an instance of a
ConcurrentMap which can be used by module builders to store
request specific properties in a thread-safe way. |
Modifier and Type | Method and Description |
---|---|
javax.servlet.http.HttpServlet |
asServlet()
Returns this instance of the aggregator as a HttpServlet.
|
Future<?> |
buildAsync(Callable<?> builder,
javax.servlet.http.HttpServletRequest request)
Runs the specified builder on an asynchronous thread and returns a
Future to the
result. |
ICacheManager |
getCacheManager()
Returns the cache manager object for this aggregator.
|
IConfig |
getConfig()
Returns the config object for this aggregator.
|
javax.servlet.http.HttpServletRequest |
getCurrentRequest()
Returns the request object currently being processed.
|
IDependencies |
getDependencies()
Returns the dependencies object for this aggregator.
|
IExecutors |
getExecutors() |
Iterable<IAggregatorExtension> |
getExtensions(String extensionPointId)
Returns an
Iterable for the collection of aggregator extensions identified by
extensionPointId . |
InitParams |
getInitParams()
Returns the servlet init-params for this aggregator.
|
IModuleBuilder |
getModuleBuilder(String mid,
IResource res)
Returns an
IModuleBuilder for the specified arguments. |
String |
getName()
Returns the name of the servlet implementing this interface.
|
IOptions |
getOptions()
Returns the options object for this aggregator.
|
IPlatformServices |
getPlatformServices()
Get the
IPlatformServices implementation for this aggregator. |
IResourceFactory |
getResourceFactory(org.apache.commons.lang3.mutable.Mutable<URI> uri)
Returns a new
IResourceFactory for the specified URI. |
IHttpTransport |
getTransport()
Returns the HTTP transport in use by this object
|
File |
getWorkingDirectory()
Returns this aggregator's working directory.
|
IGzipCache |
newGzipCache()
Factory method for IGZipCache
|
ILayerCache |
newLayerCache()
Factory method for ILayerCache
|
IModule |
newModule(String mid,
URI uri)
Factory method for IModule instances.
|
IModuleCache |
newModuleCache()
Factory method for IModuleCache
|
IResource |
newResource(URI uri)
Returns a new
IResource for the specified URI. |
boolean |
reloadConfig()
Reloads the config data using the latest values in the config file
specified in the
config init-param of the servlet. |
IResource |
runConverters(IResource res)
Run the registered resource converters against the specified resource.
|
String |
setForceError(String forceError)
Command provider function for setting forced errors in development mode.
|
String |
substituteProps(String str)
Performs substitution of variable names of the form ${name} with the values
defined in java system properties, or with the value returned by a registered
variable resolver that implements the interface
IVariableResolver . |
String |
substituteProps(String str,
IAggregator.SubstitutionTransformer transformer)
Like
substituteProps(String) , but allows the caller to specify
a transformer class to process the substitution values. |
static final String AGGREGATOR_REQATTRNAME
IAggregator
instance
associated with a given requeststatic final String CONCURRENTMAP_REQATTRNAME
ConcurrentMap
which can be used by module builders to store
request specific properties in a thread-safe way.String getName()
IConfig getConfig()
config
servlet init-param. The URI
specified by this init-param points to a server side AMD config file that
specifies the aggregator config propertes using JSON format in the same
way that the client side loader config JSON specifies the AMD
configuration for the loader on the client. \IOptions getOptions()
IExecutors getExecutors()
ICacheManager getCacheManager()
IDependencies getDependencies()
IHttpTransport getTransport()
String setForceError(String forceError)
forceError
- the error parameters. See ForcedErrorResponse.ForcedErrorResponse(String)
for description.IResourceFactory getResourceFactory(org.apache.commons.lang3.mutable.Mutable<URI> uri)
IResourceFactory
for the specified URI. The aggregator
will create the new resource using one of the registered resource
factories.
The aggregator will select the factory from among the registered IResourceFactory
extensions by testing the provided uri
against the scheme attribute of each of the
registered resource factories as follows:
Iterate through the registered resource factory extensions looking for extensions that
specify a scheme
attribute matching the scheme of uri
or a
scheme
attribute of *
. For each matching extension, call the
IResourceFactory.handles(URI)
method and if the method returns true, then call the
IResourceFactory.newResource(URI)
method to create the new resource.
The iteration order of the resource factories is determined by the order that
resourcefactories
init-params are declared within the servlet
element defining the aggregator servlet, the order that the factory
elements are
declared in the resource factory extensions within the plugin.xml{s}, and on the insertion
positions of extensions registered programatically using
IExtensionInitializer.IExtensionRegistrar.registerExtension(java.lang.Object, java.util.Properties, com.ibm.jaggr.core.InitParams, java.lang.String, java.lang.String, com.ibm.jaggr.core.IAggregatorExtension)
.
The registered resource factory extensions may be obtained by calling
getExtensions(String)
;
If a satisfactory resource factory cannot be found, then null is returned.
uri
- (Input/Output)
A mutable reference to the input uri which may be modified to reference a
different uri for the same resource if the uri needs to be transformed in order to
match to a resource factory (e.g. a relative uri transformed into an absolute
uri).IResource newResource(URI uri)
IResource
for the specified URI. The aggregator
will create the new resource using the resource factory obtained by
calling getResourceFactory(Mutable)
.
This method may return an instance of NotFoundResource
if a resource factory
for the URI cannot be found.
This method calls runConverters(IResource)
against the resource
obtained from the resource factory before returning the result.
uri
- The URI for the resourceIResource runConverters(IResource res)
Note that this method is called automatically by newResource(URI)
, so it is
generally not necessary to call this method directly.
res
- the resource to run converters againstres
if no conversion is applied.IModuleBuilder getModuleBuilder(String mid, IResource res)
IModuleBuilder
for the specified arguments. The aggregator will select the
builder from among the registered module builder extensions by testing the provided
mid
and res
arguments against the attributes for each of the
registered extensions as follows:
Iterate through the registered module builder extensions looking for extensions that specify
an extension
attribute that matches the file extension of the resource specified
by res
or an extension
attribute of *
. For each
matching module builder extension, if the extension does not specify a plugin
attribute or the value of the plugin
attribute matches the plugin specified by
mid
(if any), then call the module builder's
IModuleBuilder.handles(String, IResource)
method. If the method returns true, then
the module builder is returned to the caller.
The iteration order of the module builders is determined by the order that
modulebuilders
init-params are declared within the servlet
element
defining the aggregator servlet, the order that the builder
elements are
declared in the module builder extensions within the plugin.xml{s}, and on the insertion
positions of extensions registered programatically using
IExtensionInitializer.IExtensionRegistrar.registerExtension(java.lang.Object, java.util.Properties, com.ibm.jaggr.core.InitParams, java.lang.String, java.lang.String, com.ibm.jaggr.core.IAggregatorExtension)
.
The registered module builder extensions may be obtained by calling
getExtensions(String)
.
mid
- The module id for the module to be builtres
- The resource for the moduleInitParams getInitParams()
File getWorkingDirectory()
boolean reloadConfig() throws IOException
config
init-param of the servlet.
Any services registered using the IConfigListener
interface are
notified.
IOException
javax.servlet.http.HttpServlet asServlet()
Iterable<IAggregatorExtension> getExtensions(String extensionPointId)
Iterable
for the collection of aggregator extensions identified by
extensionPointId
. This includes extensions obtained from the eclipse extension
registry, as well as extensions registered though the IExtensionInitializer.IExtensionRegistrar
interface.extensionPointId
- The extension point id for the extensions to be returned, or null for all
extensions.IModule newModule(String mid, URI uri)
mid
- the module iduri
- the URI to the module sourceILayerCache newLayerCache()
IModuleCache newModuleCache()
IGzipCache newGzipCache()
String substituteProps(String str)
IVariableResolver
.
Variable resolvers are registered in the OSGi service registry. If more than
one resolver is registered, the first one that returns a value for the variable
will be used. If no value is found for a variable, then the variable
identifier is unmodified in the returned string.str
- The string for which variables should be substitutedString substituteProps(String str, IAggregator.SubstitutionTransformer transformer)
substituteProps(String)
, but allows the caller to specify
a transformer class to process the substitution values.str
- The input stringtransformer
- An instance of IAggregator.SubstitutionTransformer
IPlatformServices getPlatformServices()
IPlatformServices
implementation for this aggregator.IPlatformServices
Future<?> buildAsync(Callable<?> builder, javax.servlet.http.HttpServletRequest request)
Future
to the
result. Saves request
to a thread local that can be queried by the async thread
using getCurrentRequest()
.builder
- the builder to runrequest
- the request objectjavax.servlet.http.HttpServletRequest getCurrentRequest()
buildAsync(Callable, HttpServletRequest)
.
For all other threads, the return value will be null.Copyright © 2011-2015 IBM. All Rights Reserved.