public interface IHttpTransport extends IExtensionInitializer
This interface also provides the AMD loader extension JavaScript used to format and send the requests to the aggregator.
Modifier and Type | Interface and Description |
---|---|
static class |
IHttpTransport.LayerContributionType
Enum defining the constants for the various layer contribution types.
|
static class |
IHttpTransport.ModuleInfo |
static class |
IHttpTransport.OptimizationLevel
Supported optimization levels.
|
IExtensionInitializer.IExtensionRegistrar
Modifier and Type | Field and Description |
---|---|
static String |
ASSERTNONLS_REQATTRNAME
Name of the request attribute specifying if the server should assert that the modules
specified by the
deps and/or preloads
request parameters, plus their nested dependencies, include no nls modules. |
static String |
CACHEBUST_REQATTRNAME
Name of the request attributes containing any recognized cache bust
argument from the request.
|
static String |
CONFIGVARNAME_REQATTRNAME
Name of the request attribute specifying the config var name used to
configure the loader on the client.
|
static String |
DEPENDENCYEXPANSIONLOGGING_REQATTRNAME
Name of the request attribute specifying the Boolean flag indicating if debug logging output
about dependency expansion should be displayed in the browser console
|
static String |
EXPANDREQLOGGING_REQATTRNAME
Deprecated.
this constant is deprecated in favor of the
DEPENDENCYEXPANSIONLOGGING_REQATTRNAME constant |
static String |
EXPANDREQUIRELISTS_REQATTRNAME
Name of the request attribute specifying the Boolean flag indicating if
dependency lists in require() calls should be expanded to include nested
dependencies.
|
static String |
EXPORTMODULENAMES_REQATTRNAME
Name of the request attribute specifying the Boolean flag indicating if
the aggregator should export the name of the requested module in the
define() functions of anonymous modules.
|
static String |
FEATUREMAP_REQATTRNAME
Name of the request attribute specifying the
Feature object
for the feature set specified in the request |
static String |
GENERATESOURCEMAPS_REQATTRNAME
Name of request attribute specifying if source maps should be generated for this
request.
|
static String |
INCLUDEREQUIREDEPS_REQATTRNAME
Name of the request attribute specifying whether or not dependencies specified in require
calls that are contained within AMD modules should be expanded when performing server-side
expansion of dependent modules.
|
static String |
INCLUDEUNDEFINEDFEATUREDEPS_REQATTRNAME
Name of the request attribute specifying whether or not dependencies specified using has!
loader plugin conditionals for undefined features (either in define or require dependencies)
should be included when performing server-side expansion of dependent modules.
|
static String |
NOADDMODULES_REQATTRNAME
Specifies that the module builders may not add module resources that were
not explicitly requested by the loader to the response.
|
static String |
NOCACHE_REQATTRNAME
Name of the request attribute specifying the Boolean flag indicating if
the responses should not be cached.
|
static String |
NOTEXTADORN_REQATTRNAME
Specifies that the text module builder should not wrap the text
in an AMD define(...) function call, and instead should return
the text content as an unadorned string.
|
static String |
OPTIMIZATIONLEVEL_REQATTRNAME
Name of the request attribute specifying the
IHttpTransport.OptimizationLevel
specifying the requested optimization level for module builds. |
static String |
REQUESTEDLOCALES_REQATTRNAME
Name of the request attribute specifying a
Collection;<String>
containing set of requested locales. |
static String |
REQUESTEDMODULENAMES_REQATTRNAME
Name of the request attribute specifying the requested module names.
|
static String |
SERVEREXPANDLAYERS_REQATTRNAME
Name of the request attribute specifying if server expansion of dependencies for
requested modules should be performed.
|
static String |
SHOWFILENAMES_REQATTRNAME
Name of the request attribute specifying the Boolean flag indicating if
the response should be annotated with comments indicating the names of
the module source files.
|
Modifier and Type | Method and Description |
---|---|
void |
contributeLoaderExtensionJavaScript(String contribution)
Called by aggregator extensions to contribute JavaScript that will be
included in the loader extension JavaScript module that is loaded by the
client.
|
void |
decorateRequest(javax.servlet.http.HttpServletRequest request)
Called to parse the HTTP request and decorate the request with the
request attributes defined in this interface.
|
String |
getAggregatorTextPluginName()
Returns the plugin name used by the transport for text resources (e.g.
|
List<ICacheKeyGenerator> |
getCacheKeyGenerators()
Returns a cache key generator for the JavaScript contained in the
loader extension JavaScript and output by
getLayerContribution(HttpServletRequest, LayerContributionType, Object)
. |
String |
getLayerContribution(javax.servlet.http.HttpServletRequest request,
IHttpTransport.LayerContributionType type,
Object arg)
Returns a string value that will be added to the layer in the location
specified by
type , or null if the transport has no contribution
to make. |
Map<String,Integer> |
getModuleIdMap()
Returns a map of module name to module id pairs that can be used to encode the module names
when requesting modules.
|
String |
getModuleIdRegFunctionName()
Returns the name of the client side registration function used to register module-name/module-id
mappings.
|
boolean |
isServerExpandable(javax.servlet.http.HttpServletRequest request,
String mid)
Returns true if the specified module can be included in a server expanded
layer (i.e.
|
initialize
static final String REQUESTEDMODULENAMES_REQATTRNAME
IRequestedModuleNames
.
The object's toString() method must return a string representation of the list that can be used to uniquely identify the order and items in the list for use as a cache key. Implementors may choose to provide a condensed presentation for the sake of efficiency, however, non-displayable characters should be avoided.
static final String FEATUREMAP_REQATTRNAME
Feature
object
for the feature set specified in the requeststatic final String OPTIMIZATIONLEVEL_REQATTRNAME
IHttpTransport.OptimizationLevel
specifying the requested optimization level for module builds. Not all
module builders may support all (or any) levels.static final String EXPANDREQUIRELISTS_REQATTRNAME
static final String EXPORTMODULENAMES_REQATTRNAME
static final String REQUESTEDLOCALES_REQATTRNAME
Collection;<String>
containing set of requested locales. How the requested locales are determined
is implementation specific.static final String EXPANDREQLOGGING_REQATTRNAME
DEPENDENCYEXPANSIONLOGGING_REQATTRNAME
constantstatic final String DEPENDENCYEXPANSIONLOGGING_REQATTRNAME
static final String SHOWFILENAMES_REQATTRNAME
static final String NOCACHE_REQATTRNAME
static final String CACHEBUST_REQATTRNAME
static final String NOTEXTADORN_REQATTRNAME
static final String NOADDMODULES_REQATTRNAME
EXPORTMODULENAMES_REQATTRNAME
or
OPTIMIZATIONLEVEL_REQATTRNAME
) then module expansion may not be
supported for the current request. Module builders may specify additional
modules to be included in the response using the ModuleBuild
constructor that accepts a list of IModule
objects. If this
request attribute is true, then the list of additional modules specified
in the ModuleBuild
constructor will be ignored.static final String CONFIGVARNAME_REQATTRNAME
This information is used by the javascript module builder to locate
the loader config deps
property in order to expand the
modules specified by that property to include nested dependencies.
This request attribute is not required to be present if no config var name was specified in the request.
static final String INCLUDEREQUIREDEPS_REQATTRNAME
deps
and/or preloads
request parameters.
This request attribute corresponds to the includeRequireDeps
request parameter
and is set by the transport based on the value of the request parameter.
static final String INCLUDEUNDEFINEDFEATUREDEPS_REQATTRNAME
deps
and/or preloads
request parameters.
If this attribute is true, then the modules specified by both branches of a has! plugin conditional for an undefined feature will be added to the layer being built, along with both of those modules' dependencies.
This request attribute corresponds to the includeUndefinedFeatureDeps
request
parameter and is set by the transport based on the value of the request parameter.
static final String ASSERTNONLS_REQATTRNAME
deps
and/or preloads
request parameters, plus their nested dependencies, include no nls modules. This is
helpful for keeping nls resources out of the bootstrap layer in cases where code needs
to run on the client to determine the user's preferred locale. If this options is
specified and the response would contain nls resources, then a 400 - Bad Request
response status is returned.
This request attribute corresponds to the assertNoNLS
request
parameter and is set by the transport based on the value of the request parameter.
static final String SERVEREXPANDLAYERS_REQATTRNAME
IRequestedModuleNames.getModules()
) will be included in the response, excluding
the modules specified by IRequestedModuleNames.getExcludes()
and their dependencies.
This options take precedence over EXPANDREQUIRELISTS_REQATTRNAME
in the event that both are specified.
static final String GENERATESOURCEMAPS_REQATTRNAME
void decorateRequest(javax.servlet.http.HttpServletRequest request) throws IOException
request
- The HTTP requestIOException
void contributeLoaderExtensionJavaScript(String contribution)
The loader extension JavaScript is loaded before the AMD loader. Code contributed to the loader extension JavaScript may modify or augment the loader config, such as adding paths or aliases, etc.
In addition, this interface defines the property
urlProcessors
which is in scope when the JavaScript
contributed by this method is run. This property is an array of functions
that are each called just before a request is sent to the aggregator. The
function takes a single parameter which is the aggregator URL and it
returns the same or updated URL. Extensions wishing to contribute query
args to aggregator URLs, or otherwise modify the URL, may do so by adding
a url processor function to this array in the JavaScript contribution as
shown in the following example:
urlProcessors.push(function(url) {return url+'&foo=bar'});
The mechanism by which the loader extension JavaScript is delivered to
the client is outside the scope of this interface. A typical implementation
will register an IResourceFactory
which returns an IResource
object that will deliver the loader extension JavaScript when the AMD module
which has been mapped to the resource URI for the loader extension JavaScript
is requested.
contribution
- The JavaScript being contributed.String getLayerContribution(javax.servlet.http.HttpServletRequest request, IHttpTransport.LayerContributionType type, Object arg)
type
, or null if the transport has no contribution
to make. This method is provided to allow the transport to inject
scaffolding JavaScript that may be required by the AMD loader.request
- The request objecttype
- The layer contribution typearg
- This parameter specifies a IHttpTransport.ModuleInfo
object for the following
type
values:
IHttpTransport.LayerContributionType.BEFORE_FIRST_MODULE
IHttpTransport.LayerContributionType.BEFORE_SUBSEQUENT_MODULE
IHttpTransport.LayerContributionType.AFTER_MODULE
IHttpTransport.LayerContributionType.BEFORE_FIRST_LAYER_MODULE
IHttpTransport.LayerContributionType.BEFORE_SUBSEQUENT_LAYER_MODULE
IHttpTransport.LayerContributionType.AFTER_LAYER_MODULE
type
, arg
specifies
a Set<String>
of modules which are to be required by the
loader via a synthetically generated require() call.
IHttpTransport.LayerContributionType.BEGIN_LAYER_MODULES
IHttpTransport.LayerContributionType.END_LAYER_MODULES
type
, mid
is null.type
.boolean isServerExpandable(javax.servlet.http.HttpServletRequest request, String mid)
Excluded modules consist of those that specify a loader plugin that is not
included in IConfig.TEXTPLUGINDELEGATORS_CONFIGPARAM
or
IConfig.JSPLUGINDELEGATORS_CONFIGPARAM
, and modules that specify
an absolute or server relative URL.
request
- The request objectmid
- The module idList<ICacheKeyGenerator> getCacheKeyGenerators()
getLayerContribution(HttpServletRequest, LayerContributionType, Object)
. If the output JavaScript is invariant with regard to the request for
the same set of modules, then this function may return null.Map<String,Integer> getModuleIdMap()
String getModuleIdRegFunctionName()
[ [ ["module1", "module2", "module3"], ["module4"], ["module5", "module6"] ], [ [1,2,3], [4], [5,6] ] ]
The JavaScript module builder emits code to register module-ids for expanded dependencies on the client, using the string arrays (the first element) both to specify the expanded dependencies and as part of the id mappings.
The id mappings are used by the client to encode requested module names when requesting modules from the aggregator in order to minimize URL lengths.
String getAggregatorTextPluginName()
Copyright © 2011-2015 IBM. All Rights Reserved.