public abstract class ModuleSourceProviderBase extends java.lang.Object implements ModuleSourceProvider, java.io.Serializable
NOT_MODIFIED
Constructor and Description |
---|
ModuleSourceProviderBase() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
entityNeedsRevalidation(java.lang.Object validator)
Override to determine whether according to the validator, the cached
module script needs revalidation.
|
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 abstract 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.
|
ModuleSource |
loadSource(java.lang.String moduleId,
Scriptable paths,
java.lang.Object validator)
Returns the script source of the requested module.
|
ModuleSource |
loadSource(java.net.URI uri,
java.net.URI base,
java.lang.Object validator)
Returns the script source of the requested module from the given URI.
|
public ModuleSource loadSource(java.lang.String moduleId, Scriptable paths, java.lang.Object validator) throws java.io.IOException, java.net.URISyntaxException
ModuleSourceProvider
ModuleSourceProvider.NOT_MODIFIED
should be returned. Otherwise, it should
return a ModuleSource
object with the actual source text of the
module, preferrably a validator for it, and a security domain, where
applicable.loadSource
in interface ModuleSourceProvider
moduleId
- the ID of the module. An implementation must only accept
an absolute ID, starting with a term.paths
- the value of the require() function's "paths" attribute. If
the require() function is sandboxed, it will be null, otherwise it will
be a JavaScript Array object. It is up to the provider implementation
whether and how it wants to honor the contents of the array.validator
- a validator for an existing loaded and cached module.
This will either be null, or an object that this source provider
returned earlier as part of a ModuleSource
. It can be used to
validate the existing cached module and avoid reloading it.ModuleSourceProvider.NOT_MODIFIED
should be
returned if the passed validator validates the current representation of
the module (the currently cached module script).java.io.IOException
- if there was an I/O problem reading the scriptjava.net.URISyntaxException
- if the final URI could not be constructed.public ModuleSource loadSource(java.net.URI uri, java.net.URI base, java.lang.Object validator) throws java.io.IOException, java.net.URISyntaxException
ModuleSourceProvider
If the resource is not found, null is returned. If the caller passes a
non-null validator, and the source provider recognizes it, and the
validator applies to the same resource that the provider would use to
load the source, and the validator validates the current cached
representation of the resource (using whatever semantics for validation
that this source provider implements), then ModuleSourceProvider.NOT_MODIFIED
should be returned. Otherwise, it should return a ModuleSource
object with the actual source text of the module, preferrably a
validator for it, and a security domain, where applicable.
loadSource
in interface ModuleSourceProvider
uri
- the absolute URI from which to load the module source, but
without an extension such as ".js".base
- the module path base URI from which uri
was derived.validator
- a validator for an existing loaded and cached module.
This will either be null, or an object that this source provider
returned earlier as part of a ModuleSource
. It can be used to
validate the existing cached module and avoid reloading it.ModuleSourceProvider.NOT_MODIFIED
should be
returned if the passed validator validates the current representation of
the module (the currently cached module script).java.io.IOException
- if there was an I/O problem reading the scriptjava.net.URISyntaxException
- if the final URI could not be constructedprotected boolean entityNeedsRevalidation(java.lang.Object validator)
validator
- the validatorprotected abstract ModuleSource loadFromUri(java.net.URI uri, java.net.URI base, java.lang.Object validator) throws java.io.IOException, java.net.URISyntaxException
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 loadFromPrivilegedLocations(java.lang.String moduleId, java.lang.Object validator) throws java.io.IOException, java.net.URISyntaxException
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
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.