public abstract class AbstractModuleRegistry extends Object
This tracks all the built-in modules that are available to us. There are three types of modules:
There are two types of registries -- the root registry loads classes from the classloader that was used to load Trireme, and there is one in the environment for each node implementation. It is used for all the built-in modules for each version of Node.
A child registry can be used to load new classes (specifically for script-specific native classes loaded using the "trireme-support" module) and delegates to the rest.
The constructor for this class manually defines all compiled script modules. All the rest are loaded using the ServiceLoader, which means that new modules can add new scripts.
This registry is loaded based on a NodeImplementation, which means that there can be many if there are a lot of versions of Node available.
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractModuleRegistry.ModuleType |
| Constructor and Description |
|---|
AbstractModuleRegistry() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addNativeModule(NodeModule mod) |
abstract NodeModule |
get(String name)
Get a "regular" module, loadable via "require".
|
abstract org.mozilla.javascript.Script |
getCompiledModule(String name)
Get a pre-compiled script, loaded via NodeScriptModule.
|
abstract Set<String> |
getCompiledModuleNames() |
abstract NodeImplementation |
getImplementation() |
abstract NodeModule |
getInternal(String name)
Get an "internal" module, loadable via "process.binding".
|
abstract org.mozilla.javascript.Script |
getMainScript() |
abstract NodeModule |
getNative(String name)
Get a "native" module -- a replacement for native code, loadable via "dlopen".
|
void |
load(org.mozilla.javascript.Context cx,
ClassLoader cl)
Load modules from the classloader and store them in this registry.
|
abstract void |
loadRoot(org.mozilla.javascript.Context cx)
To be called once per script invocation, at startup.
|
protected abstract void |
putCompiledModule(String name,
org.mozilla.javascript.Script script) |
protected abstract void |
putInternalModule(String name,
InternalNodeModule mod) |
protected abstract void |
putNativeModule(String name,
NativeNodeModule mod) |
protected abstract void |
putRegularModule(String name,
NodeModule mod) |
public abstract NodeImplementation getImplementation()
public abstract void loadRoot(org.mozilla.javascript.Context cx)
public abstract NodeModule get(String name)
public abstract NodeModule getInternal(String name)
public abstract NodeModule getNative(String name)
public abstract org.mozilla.javascript.Script getCompiledModule(String name)
public abstract org.mozilla.javascript.Script getMainScript()
protected abstract void putCompiledModule(String name, org.mozilla.javascript.Script script)
protected abstract void putInternalModule(String name, InternalNodeModule mod)
protected abstract void putNativeModule(String name, NativeNodeModule mod)
protected abstract void putRegularModule(String name, NodeModule mod)
public void load(org.mozilla.javascript.Context cx,
ClassLoader cl)
protected void addNativeModule(NodeModule mod)
Copyright © 2016 Apigee Corporation. All Rights Reserved.