| java.lang.Object pnuts.ext.ModuleBase
All known Subclasses: pnuts.security.init, pnuts.nio.init, pnuts.awt.init, pnuts.multithread.init, pnuts.text.init, pnuts.regex.init, pnuts.net.init, org.pnuts.java_io.init, pnuts.mail.init, org.pnuts.java_net.init, pnuts.jmx.init, org.pnuts.java_util.init, pnuts.io.init, pnuts.math.init, pnuts.beans.init, pnuts.tools.init, pnuts.util.init, pnuts.lib.init, pnuts.xml.init, pnuts.servlet.init, pnuts.jdbc.init, pnuts.jdo.init, pnuts.regex.jsr51.init,
ModuleBase | abstract public class ModuleBase implements Executable,Serializable(Code) | | Base class of modules. This class provides convenient autloading functions
and an error reporting function. Modules may (or may not) subclass this
class.
|
Method Summary | |
protected void | autoload(String[] functionNames, String file, Context context) Registers an autoloaded script for functionNames. | protected void | autoloadClass(String javaPackage, String name, Context context) Registers an autoloaded Class object.
Parameters: javaPackage - Java package name, e.g. | protected void | autoloadFunction(String functionName, Context context) Registers an autoloaded class for functionName. | static PnutsFunction | errorFunction() | protected Object | execute(Context context) Subclasses should override this method, instead of run(Context), to
define the initialization process.
If neither getSubModules() nor getRequiredModules() are redefined
to return non-null value, execute() method should be implemented
as the following steps.
1. | static Property | exports(Package pkg) | AutoloadFunction | getAutoloadFunctionHook(Package pkg) | protected String | getClassName(Package pkg, String name) Makes a class name for the specified package and the symbol's name. | protected Package | getPackage(Context context) | protected String | getPrefix() Defines the prefix of script class (resource) name. | protected 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 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 Object | newInstance(Class cls) This method is redefined in subclasses so that package private classes
can be used. | public Object | run(Context context) Defines ERROR and EXPORTS, and then call execute(Context). |
autoload | protected void autoload(String[] functionNames, String file, Context context)(Code) | | Registers an autoloaded script for functionNames. Also, functionNames are
automatically exported.
Parameters: functionNames - the function names Parameters: file - a script file to be loaded when one of the functionNames isfirst resolved. Parameters: context - the context |
autoloadClass | protected void autoloadClass(String javaPackage, String name, Context context)(Code) | | Registers an autoloaded Class object.
Parameters: javaPackage - Java package name, e.g. "java.util" Parameters: name - short Class name, e.g. "HashMap" Parameters: context - the context |
autoloadFunction | protected void autoloadFunction(String functionName, Context context)(Code) | | Registers an autoloaded class for functionName. Also, the functionName is
automatically exported.
Parameters: functionName - the function name Parameters: context - the context |
execute | protected Object execute(Context context)(Code) | | Subclasses should override this method, instead of run(Context), to
define the initialization process.
If neither getSubModules() nor getRequiredModules() are redefined
to return non-null value, execute() method should be implemented
as the following steps.
1. Call context.usePackage() to use the modules that this module provides
2. Call context.clearPackages()
3. Call context.usePackage() to use the module that this module requires
4. Define symbols (functions)
Parameters: context - the context |
getAutoloadFunctionHook | AutoloadFunction getAutoloadFunctionHook(Package pkg)(Code) | | |
getClassName | protected String getClassName(Package pkg, String name)(Code) | | Makes a class name for the specified package and the symbol's name.
Parameters: pkg - the package Parameters: name - the symbol the name of the class |
getPrefix | protected String getPrefix()(Code) | | Defines the prefix of script class (resource) name.
This method is overriden by subclasses.
|
getRequiredModules | protected String[] getRequiredModules()(Code) | | This method is supposed to be redefined in a subclass to
define a set of modules that are required to implement this module.
If this method returns an array of module names (non-null),
Context.clearPackages() is called, then the modules are used()'d,
before calling execute() method.
|
getSubModules | protected String[] getSubModules()(Code) | | 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.
If this method returns an array of module names (non-null),
they are use()'d, then Context.clearPackages() is called, before
calling execute() method.
|
run | public Object run(Context context)(Code) | | Defines ERROR and EXPORTS, and then call execute(Context).
Parameters: context - the context |
|
|