Class SoftCachingModuleScriptProvider
- java.lang.Object
- 
- org.mozilla.javascript.commonjs.module.provider.CachingModuleScriptProviderBase
- 
- org.mozilla.javascript.commonjs.module.provider.SoftCachingModuleScriptProvider
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- ModuleScriptProvider
 
 public class SoftCachingModuleScriptProvider extends CachingModuleScriptProviderBase A module script provider that uses a module source provider to load modules and caches the loaded modules. It softly references the loaded modules' RhinoScriptobjects, 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.- See Also:
- Serialized Form
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class org.mozilla.javascript.commonjs.module.provider.CachingModuleScriptProviderBaseCachingModuleScriptProviderBase.CachedModuleScript
 
- 
 - 
Constructor SummaryConstructors Constructor Description SoftCachingModuleScriptProvider(ModuleSourceProvider moduleSourceProvider)Creates a new module provider with the specified module source provider.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CachingModuleScriptProviderBase.CachedModuleScriptgetLoadedModule(java.lang.String moduleId)Retrieves an already loaded moduleScript stored usingCachingModuleScriptProviderBase.putLoadedModule(String, ModuleScript, Object).ModuleScriptgetModuleScript(Context cx, java.lang.String moduleId, java.net.URI uri, java.net.URI base, Scriptable paths)Returns a module script.protected voidputLoadedModule(java.lang.String moduleId, ModuleScript moduleScript, java.lang.Object validator)Store a loaded module script for later retrieval usingCachingModuleScriptProviderBase.getLoadedModule(String).- 
Methods inherited from class org.mozilla.javascript.commonjs.module.provider.CachingModuleScriptProviderBasegetConcurrencyLevel
 
- 
 
- 
- 
- 
Constructor Detail- 
SoftCachingModuleScriptProviderpublic SoftCachingModuleScriptProvider(ModuleSourceProvider moduleSourceProvider) Creates a new module provider with the specified module source provider.- Parameters:
- moduleSourceProvider- provider for modules' source code
 
 
- 
 - 
Method Detail- 
getModuleScriptpublic ModuleScript getModuleScript(Context cx, java.lang.String moduleId, java.net.URI uri, java.net.URI base, Scriptable paths) throws java.lang.Exception Description copied from interface:ModuleScriptProviderReturns a module script. It should attempt to load the module script if it is not already available to it, or return an already loaded module script instance if it is available to it.- Specified by:
- getModuleScriptin interface- ModuleScriptProvider
- Overrides:
- getModuleScriptin class- CachingModuleScriptProviderBase
- Parameters:
- 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- moduleIdis bypassed and the script is directly loaded from- moduleUri
- base- the module path base URI from which- moduleUriwas 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.
- Returns:
- a module script representing the compiled code of the module. Null should be returned if the script could not found.
- Throws:
- java.lang.Exception- if there was an unrecoverable problem obtaining the script
- java.lang.IllegalArgumentException- if the module ID is syntactically not a valid absolute module identifier.
 
 - 
getLoadedModuleprotected CachingModuleScriptProviderBase.CachedModuleScript getLoadedModule(java.lang.String moduleId) Description copied from class:CachingModuleScriptProviderBaseRetrieves an already loaded moduleScript stored usingCachingModuleScriptProviderBase.putLoadedModule(String, ModuleScript, Object).- Specified by:
- getLoadedModulein class- CachingModuleScriptProviderBase
- Parameters:
- moduleId- the ID of the module
- Returns:
- a cached module script, or null if the module is not loaded.
 
 - 
putLoadedModuleprotected void putLoadedModule(java.lang.String moduleId, ModuleScript moduleScript, java.lang.Object validator)Description copied from class:CachingModuleScriptProviderBaseStore a loaded module script for later retrieval usingCachingModuleScriptProviderBase.getLoadedModule(String).- Specified by:
- putLoadedModulein class- CachingModuleScriptProviderBase
- Parameters:
- moduleId- the ID of the module
- moduleScript- the module script
- validator- the validator for the module's source text entity
 
 
- 
 
-