public abstract class CachingModuleScriptProviderBase extends java.lang.Object implements ModuleScriptProvider, java.io.Serializable
ModuleSourceProvider to obtain the source text of the
scripts. It supports a cache revalidation mechanism based on validator
objects returned from the ModuleSourceProvider. Instances of this
class and its subclasses are thread safe (and written to perform decently
under concurrent access).| Modifier and Type | Class and Description |
|---|---|
static class |
CachingModuleScriptProviderBase.CachedModuleScript
Instances of this class represent a loaded and cached module script.
|
| Modifier | Constructor and Description |
|---|---|
protected |
CachingModuleScriptProviderBase(ModuleSourceProvider moduleSourceProvider)
Creates a new module script provider with the specified source.
|
| Modifier and Type | Method and Description |
|---|---|
protected static int |
getConcurrencyLevel()
Returns the internal concurrency level utilized by caches in this JVM.
|
protected abstract CachingModuleScriptProviderBase.CachedModuleScript |
getLoadedModule(java.lang.String moduleId)
Retrieves an already loaded moduleScript stored using
putLoadedModule(String, ModuleScript, Object). |
ModuleScript |
getModuleScript(Context cx,
java.lang.String moduleId,
java.net.URI moduleUri,
java.net.URI baseUri,
Scriptable paths)
Returns a module script.
|
protected abstract void |
putLoadedModule(java.lang.String moduleId,
ModuleScript moduleScript,
java.lang.Object validator)
Store a loaded module script for later retrieval using
getLoadedModule(String). |
protected CachingModuleScriptProviderBase(ModuleSourceProvider moduleSourceProvider)
moduleSourceProvider - provider for modules' source codepublic ModuleScript getModuleScript(Context cx, java.lang.String moduleId, java.net.URI moduleUri, java.net.URI baseUri, Scriptable paths) throws java.lang.Exception
ModuleScriptProvidergetModuleScript in interface ModuleScriptProvidercx - current context. Can be used to compile module scripts.moduleId - the ID of the module. An implementation must only accept
an absolute ID, starting with a term.moduleUri - the URI of the module. If this is not null, resolution
of moduleId is bypassed and the script is directly loaded
from moduleUribaseUri - the module path base URI from which moduleUri
was derived.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.java.lang.Exception - if there was an unrecoverable problem obtaining the
scriptjava.lang.IllegalArgumentException - if the module ID is syntactically not a
valid absolute module identifier.protected abstract void putLoadedModule(java.lang.String moduleId,
ModuleScript moduleScript,
java.lang.Object validator)
getLoadedModule(String).moduleId - the ID of the modulemoduleScript - the module scriptvalidator - the validator for the module's source text entityprotected abstract CachingModuleScriptProviderBase.CachedModuleScript getLoadedModule(java.lang.String moduleId)
putLoadedModule(String, ModuleScript, Object).moduleId - the ID of the moduleprotected static int getConcurrencyLevel()