public interface IEnvironment
Modifier and Type | Method and Description |
---|---|
void |
addModuleListener(IModuleListener listener) |
Object |
getModule(String name) |
<T,U extends Class<T>> |
getModule(U clazz) |
List<Object> |
getModules()
Retrieve a list of loaded modules.
|
IScriptEngine |
getScriptEngine() |
Object |
loadModule(String moduleIdentifier,
boolean useCustomNamespace)
Load a module.
|
void |
print(Object text,
boolean lineFeed)
Print to standard output.
|
void |
removeModuleListener(IModuleListener listener) |
Object |
wrap(Object toBeWrapped,
boolean useCustomNamespace)
Wrap a java instance.
|
IScriptEngine getScriptEngine()
<T,U extends Class<T>> T getModule(U clazz)
List<Object> getModules()
void print(Object text, boolean lineFeed)
text
- message to writelineFeed
- true
to add a line feed after the textvoid addModuleListener(IModuleListener listener)
void removeModuleListener(IModuleListener listener)
Object loadModule(String moduleIdentifier, boolean useCustomNamespace)
When not using a custom namespace all variables and functions are loaded to the global namespace, possibly overriding existing functions. In such cases the Java module instance is returned. When useCustomNamespace is used a dynamic script object is created and returned.In such cases the global namespace is not changed. The namespace behavior is also used for loading dependencies.
name
- name of module to loaduseCustomNamespace
- set to true
if functions and constants should not be stored to the global namespace but to a custom objectObject wrap(Object toBeWrapped, boolean useCustomNamespace)
WrapToScript
only these will be wrapped. If no annotation can be found, all public methods/constants will
be wrapped. As some target languages might not support method overloading this might result in some methods not wrapped correctly.toBeWrapped
- instance to be wrappeduseCustomNamespace
- set to true
if functions and constants should not be stored to the global namespace but to the return value only