public abstract class ModuleBase extends java.lang.Object implements Executable, java.io.Serializable
Constructor and Description |
---|
ModuleBase() |
Modifier and Type | Method and Description |
---|---|
protected void |
autoload(java.lang.String[] functionNames,
java.lang.String file,
Context context)
Registers an autoloaded script for functionNames.
|
protected void |
autoloadClass(java.lang.String javaPackage,
java.lang.String name,
Context context)
Registers an autoloaded Class object.
|
protected void |
autoloadFunction(java.lang.String functionName,
Context context)
Registers an autoloaded class for functionName.
|
protected java.lang.Object |
execute(Context context)
Subclasses should override this method, instead of run(Context), to
define the initialization process.
|
protected java.lang.String |
getClassName(Package pkg,
java.lang.String name)
Makes a class name for the specified package and the symbol's name.
|
protected Package |
getPackage(Context context) |
protected java.lang.String |
getPrefix()
Defines the prefix of script class (resource) name.
|
protected java.lang.String[] |
getRequiredModules()
This method is supposed to be redefined in a subclass to
define a set of modules that are required to implement this module.
|
protected java.lang.String[] |
getSubModules()
This method is supposed to be redefined in a subclass to
define a set of modules that this module provides in the caller's
context.
|
protected java.lang.Object |
newInstance(java.lang.Class cls)
This method is redefined in subclasses so that package private classes
can be used.
|
java.lang.Object |
run(Context context)
Defines ERROR and EXPORTS, and then call execute(Context).
|
protected void autoload(java.lang.String[] functionNames, java.lang.String file, Context context)
functionNames
- the function namesfile
- a script file to be loaded when one of the functionNames is
first resolved.context
- the contextprotected void autoloadFunction(java.lang.String functionName, Context context)
functionName
- the function namecontext
- the contextprotected void autoloadClass(java.lang.String javaPackage, java.lang.String name, Context context)
javaPackage
- Java package name, e.g. "java.util"name
- short Class name, e.g. "HashMap"context
- the contextprotected java.lang.String getPrefix()
protected java.lang.Object newInstance(java.lang.Class cls) throws java.lang.IllegalAccessException, java.lang.InstantiationException
cls
- the class to be instantiatedjava.lang.IllegalAccessException
java.lang.InstantiationException
protected java.lang.String getClassName(Package pkg, java.lang.String name)
pkg
- the packagename
- the symbolpublic java.lang.Object run(Context context)
run
in interface Executable
context
- the contextprotected java.lang.Object execute(Context context)
context
- the contextprotected java.lang.String[] getRequiredModules()
protected java.lang.String[] getSubModules()