public interface ExecutionContext
| Modifier and Type | Method and Description |
|---|---|
void |
disposer(Runnable runnable)
Adds a new disposer.
|
Engine |
getEngine()
Returns the engine instance.
|
Environment |
getEnvironment()
Returns the script environment.
|
Object |
getInstance(String type)
Returns an instance of the specified component from the registry.
|
Object |
getInstanceOrNull(String type)
Returns an instance of the specified component from the registry.
|
ScriptLogger |
getLogger()
Returns the script logger.
|
Supplier<?> |
getProvider(String type)
Returns a provider of the specified component from the registry.
|
Registry |
getRegistry()
Returns the component registry.
|
ResourcePath |
getResource()
Returns the actual script running.
|
Object |
newBean(String type)
Constructs a new instance of the specified type.
|
void |
registerMock(String path,
Object value)
Register a mock object to the specified path.
|
Object |
require(String path)
Require a new javascript file or json file relative to the current file.
|
ResourcePath |
resolve(String path)
Resolve a new file resource.
|
Object |
toNativeObject(Object value)
Converts a object to native javascript object.
|
ScriptValue |
toScriptValue(Object value)
Converts a value to a script value.
|
Engine getEngine()
ResourcePath getResource()
Environment getEnvironment()
ScriptLogger getLogger()
Registry getRegistry()
Object require(String path)
path - Absolute or relative path.ResourcePath resolve(String path)
path - Absolute or relative path.void disposer(Runnable runnable)
runnable - Disposer to add.ScriptValue toScriptValue(Object value)
value - Value to convert.Object toNativeObject(Object value)
value - Value to convert.void registerMock(String path, Object value)
path - Absolute path to the object.value - Object to return from require.Object getInstance(String type) throws Exception
type - Type of object (class-name).Exception - if anything went wrong.Object getInstanceOrNull(String type) throws Exception
type - Type of object (class-name).Exception - if anything went wrong.Supplier<?> getProvider(String type) throws Exception
type - Type of object (class-name).Exception - if anything went wrong.