public abstract class AbstractEnvironment extends AbstractScriptModule implements IEnvironment
Constructor and Description |
---|
AbstractEnvironment() |
Modifier and Type | Method and Description |
---|---|
void |
addModuleListener(IModuleListener listener) |
static IEnvironment |
getEnvironment(IScriptEngine engine) |
Object |
getModule(String name)
Resolves a loaded module and returns the Java instance.
|
<T,U extends Class<T>> |
getModule(U clazz)
Resolves a loaded module by its class.
|
List<Object> |
getModules()
Retrieve a list of loaded modules.
|
void |
initialize(IScriptEngine engine,
IEnvironment environment)
Provides script engine and environment instances.
|
String |
listModules()
List all available (visible) modules.
|
Object |
loadModule(String identifier)
Load a module.
|
void |
print(Object text)
Print to standard output.
|
void |
removeModuleListener(IModuleListener listener) |
getScriptEngine
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getScriptEngine, wrap
public final Object loadModule(String identifier)
loadModule
in interface IEnvironment
name
- name of module to loadpublic void initialize(IScriptEngine engine, IEnvironment environment)
IScriptModule
initialize
in interface IScriptModule
initialize
in class AbstractScriptModule
engine
- script engine this module is loaded inenvironment
- environment module that tracks this modulepublic final String listModules()
public final Object getModule(String name)
getModule
in interface IEnvironment
name
- name of the module to resolvenull
public <T,U extends Class<T>> T getModule(U clazz)
getModule
in interface IEnvironment
clazz
- module class to look resolvenull
public List<Object> getModules()
IEnvironment
getModules
in interface IEnvironment
public final void print(@ScriptParameter(defaultValue="") Object text)
IEnvironment
print
in interface IEnvironment
text
- text to write to standard outputpublic void addModuleListener(IModuleListener listener)
addModuleListener
in interface IEnvironment
public void removeModuleListener(IModuleListener listener)
removeModuleListener
in interface IEnvironment
public static IEnvironment getEnvironment(IScriptEngine engine)