|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mozilla.javascript.commonjs.module.provider.ModuleSourceProviderBase org.mozilla.javascript.commonjs.module.provider.UrlModuleSourceProvider
public class UrlModuleSourceProvider
A URL-based script provider that can load modules against a set of base privileged and fallback URIs. It is deliberately not named "URI provider" but a "URL provider" since it actually only works against those URIs that are URLs (and the JRE has a protocol handler for them). It creates cache validators that are suitable for use with both file: and http: URL protocols. Specifically, it is able to use both last-modified timestamps and ETags for cache revalidation, and follows the HTTP cache expiry calculation model, and allows for fallback heuristic expiry calculation when no server specified expiry is provided.
Field Summary |
---|
Fields inherited from interface org.mozilla.javascript.commonjs.module.provider.ModuleSourceProvider |
---|
NOT_MODIFIED |
Constructor Summary | |
---|---|
UrlModuleSourceProvider(java.lang.Iterable<java.net.URI> privilegedUris,
java.lang.Iterable<java.net.URI> fallbackUris)
Creates a new module script provider that loads modules against a set of privileged and fallback URIs. |
|
UrlModuleSourceProvider(java.lang.Iterable<java.net.URI> privilegedUris,
java.lang.Iterable<java.net.URI> fallbackUris,
UrlConnectionExpiryCalculator urlConnectionExpiryCalculator,
UrlConnectionSecurityDomainProvider urlConnectionSecurityDomainProvider)
Creates a new module script provider that loads modules against a set of privileged and fallback URIs. |
Method Summary | |
---|---|
protected boolean |
entityNeedsRevalidation(java.lang.Object validator)
Override to determine whether according to the validator, the cached module script needs revalidation. |
protected ModuleSource |
loadFromActualUri(java.net.URI uri,
java.net.URI base,
java.lang.Object validator)
|
protected ModuleSource |
loadFromFallbackLocations(java.lang.String moduleId,
java.lang.Object validator)
Override to obtain a module source from fallback locations. |
protected ModuleSource |
loadFromPrivilegedLocations(java.lang.String moduleId,
java.lang.Object validator)
Override to obtain a module source from privileged locations. |
protected ModuleSource |
loadFromUri(java.net.URI uri,
java.net.URI base,
java.lang.Object validator)
Override in a subclass to load a module script from a logical URI. |
protected void |
onFailedClosingUrlConnection(java.net.URLConnection urlConnection,
java.io.IOException cause)
Override if you want to get notified if the URL connection fails to close. |
protected java.net.URLConnection |
openUrlConnection(java.net.URL url)
Can be overridden in subclasses to customize the URL connection opening process. |
Methods inherited from class org.mozilla.javascript.commonjs.module.provider.ModuleSourceProviderBase |
---|
loadSource, loadSource |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UrlModuleSourceProvider(java.lang.Iterable<java.net.URI> privilegedUris, java.lang.Iterable<java.net.URI> fallbackUris)
privilegedUris
- an iterable providing the privileged URIs. Can be
null if no privileged URIs are used.fallbackUris
- an iterable providing the fallback URIs. Can be
null if no fallback URIs are used.public UrlModuleSourceProvider(java.lang.Iterable<java.net.URI> privilegedUris, java.lang.Iterable<java.net.URI> fallbackUris, UrlConnectionExpiryCalculator urlConnectionExpiryCalculator, UrlConnectionSecurityDomainProvider urlConnectionSecurityDomainProvider)
privilegedUris
- an iterable providing the privileged URIs. Can be
null if no privileged URIs are used.fallbackUris
- an iterable providing the fallback URIs. Can be
null if no fallback URIs are used.urlConnectionExpiryCalculator
- the calculator object for heuristic
calculation of the resource expiry, used when no expiry is provided by
the server of the resource. Can be null, in which case the maximum age
of cached entries without validation will be zero.urlConnectionSecurityDomainProvider
- object that provides security
domain objects for the loaded sources. Can be null, in which case the
loaded sources will have no security domain associated with them.Method Detail |
---|
protected ModuleSource loadFromPrivilegedLocations(java.lang.String moduleId, java.lang.Object validator) throws java.io.IOException, java.net.URISyntaxException
ModuleSourceProviderBase
loadFromPrivilegedLocations
in class ModuleSourceProviderBase
moduleId
- the ID of the modulevalidator
- a validator that can be used to validate an existing
cached script. Can be null if there is no cached script available.
ModuleSourceProvider.NOT_MODIFIED
if
the existing cached module script is still valid.
java.io.IOException
- if the module script was found, but an I/O exception
prevented it from being loaded.
java.net.URISyntaxException
- if the final URI could not be constructed.protected ModuleSource loadFromFallbackLocations(java.lang.String moduleId, java.lang.Object validator) throws java.io.IOException, java.net.URISyntaxException
ModuleSourceProviderBase
loadFromFallbackLocations
in class ModuleSourceProviderBase
moduleId
- the ID of the modulevalidator
- a validator that can be used to validate an existing
cached script. Can be null if there is no cached script available.
ModuleSourceProvider.NOT_MODIFIED
if
the existing cached module script is still valid.
java.io.IOException
- if the module script was found, but an I/O exception
prevented it from being loaded.
java.net.URISyntaxException
- if the final URI could not be constructed.protected ModuleSource loadFromUri(java.net.URI uri, java.net.URI base, java.lang.Object validator) throws java.io.IOException, java.net.URISyntaxException
ModuleSourceProviderBase
loadFromUri
in class ModuleSourceProviderBase
uri
- the URI of the script, without file name extension.base
- the base URI the uri was resolved from.validator
- a validator that can be used to revalidate an existing
cached source at the URI. Can be null if there is no cached source
available.
ModuleSourceProvider.NOT_MODIFIED
if it revalidated the existing
cached source against the URI.
java.io.IOException
- if the module script was found, but an I/O exception
prevented it from being loaded.
java.net.URISyntaxException
- if the final URI could not be constructedprotected ModuleSource loadFromActualUri(java.net.URI uri, java.net.URI base, java.lang.Object validator) throws java.io.IOException
java.io.IOException
protected void onFailedClosingUrlConnection(java.net.URLConnection urlConnection, java.io.IOException cause)
urlConnection
- the connectioncause
- the cause it failed to close.protected java.net.URLConnection openUrlConnection(java.net.URL url) throws java.io.IOException
URL.openConnection()
.
url
- the URL
java.io.IOException
- if an I/O error occurs.protected boolean entityNeedsRevalidation(java.lang.Object validator)
ModuleSourceProviderBase
entityNeedsRevalidation
in class ModuleSourceProviderBase
validator
- the validator
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |