public interface IEnvironment
Modifier and Type | Method and Description |
---|---|
void |
addModuleCallback(IModuleCallbackProvider callbackProvider)
Register a callback provider for module functions.
|
void |
addModuleListener(IModuleListener listener) |
static IEnvironment |
getEnvironment() |
static IEnvironment |
getEnvironment(IScriptEngine engine) |
java.lang.Object |
getModule(java.lang.String name) |
<T,U extends java.lang.Class<T>> |
getModule(U clazz) |
java.util.List<java.lang.Object> |
getModules()
Retrieve a list of loaded modules.
|
IScriptEngine |
getScriptEngine() |
java.lang.Object |
loadModule(java.lang.String moduleIdentifier,
boolean useCustomNamespace)
Load a module.
|
void |
print(java.lang.Object text,
boolean lineFeed)
Print to standard output.
|
void |
removeModuleListener(IModuleListener listener) |
java.lang.Object |
wrap(java.lang.Object toBeWrapped,
boolean useCustomNamespace)
Wrap a java instance.
|
static IEnvironment getEnvironment(IScriptEngine engine)
static IEnvironment getEnvironment()
IScriptEngine getScriptEngine()
java.lang.Object getModule(java.lang.String name)
<T,U extends java.lang.Class<T>> T getModule(U clazz)
java.util.List<java.lang.Object> getModules()
void print(java.lang.Object text, boolean lineFeed)
text
- message to writelineFeed
- true
to add a line feed after the textvoid addModuleListener(IModuleListener listener)
void removeModuleListener(IModuleListener listener)
java.lang.Object loadModule(java.lang.String moduleIdentifier, @ScriptParameter(defaultValue="false") 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.
moduleIdentifier
- name of module to loaduseCustomNamespace
- set to true
if functions and constants should not be stored to the global namespace but to a custom objectjava.lang.Object wrap(java.lang.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 onlyvoid addModuleCallback(IModuleCallbackProvider callbackProvider)
callbackProvider
- callback provider instance