public class SoftCachingModuleScriptProvider extends CachingModuleScriptProviderBase
Script
objects, thus a module once loaded can become eligible
for garbage collection if it is otherwise unused under memory pressure.
Instances of this class are thread safe.CachingModuleScriptProviderBase.CachedModuleScript
Constructor and Description |
---|
SoftCachingModuleScriptProvider(ModuleSourceProvider moduleSourceProvider)
Creates a new module provider with the specified module source provider.
|
Modifier and Type | Method and Description |
---|---|
protected CachingModuleScriptProviderBase.CachedModuleScript |
getLoadedModule(java.lang.String moduleId)
Retrieves an already loaded moduleScript stored using
CachingModuleScriptProviderBase.putLoadedModule(String, ModuleScript, Object) . |
ModuleScript |
getModuleScript(Context cx,
java.lang.String moduleId,
java.net.URI uri,
java.net.URI base,
Scriptable paths)
Returns a module script.
|
protected void |
putLoadedModule(java.lang.String moduleId,
ModuleScript moduleScript,
java.lang.Object validator)
Store a loaded module script for later retrieval using
CachingModuleScriptProviderBase.getLoadedModule(String) . |
getConcurrencyLevel
public SoftCachingModuleScriptProvider(ModuleSourceProvider moduleSourceProvider)
moduleSourceProvider
- provider for modules' source codepublic ModuleScript getModuleScript(Context cx, java.lang.String moduleId, java.net.URI uri, java.net.URI base, Scriptable paths) throws java.lang.Exception
ModuleScriptProvider
getModuleScript
in interface ModuleScriptProvider
getModuleScript
in class CachingModuleScriptProviderBase
cx
- 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.uri
- the URI of the module. If this is not null, resolution
of moduleId
is bypassed and the script is directly loaded
from moduleUri
base
- 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 CachingModuleScriptProviderBase.CachedModuleScript getLoadedModule(java.lang.String moduleId)
CachingModuleScriptProviderBase
CachingModuleScriptProviderBase.putLoadedModule(String, ModuleScript, Object)
.getLoadedModule
in class CachingModuleScriptProviderBase
moduleId
- the ID of the moduleprotected void putLoadedModule(java.lang.String moduleId, ModuleScript moduleScript, java.lang.Object validator)
CachingModuleScriptProviderBase
CachingModuleScriptProviderBase.getLoadedModule(String)
.putLoadedModule
in class CachingModuleScriptProviderBase
moduleId
- the ID of the modulemoduleScript
- the module scriptvalidator
- the validator for the module's source text entity