public class NodeScript extends Object
| Modifier and Type | Method and Description |
|---|---|
org.mozilla.javascript.Scriptable |
_getProcessObject()
An internal method to retrieve the "process" argument for sending events.
|
ScriptRunner |
_getRuntime()
An internal method to get the runtime for this script.
|
boolean |
_isChildProcess() |
void |
_setChildProcess(boolean child)
An internal method to denote that this script was spawned by another Trireme script.
|
void |
_setParentProcess(TriremeProcess parent)
An internal method to identify the child process argument of the parent who forked this script.
|
void |
addEnvironment(String name,
String value)
Add an environment variable to the script without removing anything that already exists.
|
void |
close()
Callers should close the script when done to clean up resources.
|
ScriptFuture |
execute()
Run the script and return a Future denoting its status.
|
ScriptFuture |
executeModule()
Run the script, but treat it as a module rather than as a true script.
|
Object |
getAttachment()
Callers can use this method to attach objects to the script.
|
String |
getDisplayName() |
Map<String,String> |
getEnvironment()
Get the current set of environment variables that will be passed to the script.
|
String |
getNodeVersion() |
Sandbox |
getSandbox() |
String |
getWorkingDirectory() |
boolean |
isPinned() |
boolean |
isPrintEval() |
void |
setAttachment(Object attachment)
Retrieve whatever was set by getAttachment.
|
void |
setDisplayName(String dn)
Set a name that is used in diagnostics information from the script.
|
void |
setEnvironment(Map<String,String> env)
Replace the current set of environment variables for the script with the specified set.
|
void |
setNodeVersion(String v)
Specify which version of the Node.js runtime to select for this script.
|
void |
setPinned(boolean p)
Pin the script before running it -- this ensures that the script will never exit unless process.exit
is called or the future is explicitly cancelled.
|
void |
setPrintEval(boolean print)
If the script was passed as a string when the script was created, print the result at the end.
|
void |
setSandbox(Sandbox box)
Set up a restricted environment.
|
void |
setWorkingDirectory(String wd)
Specify the working directory for this script.
|
public ScriptFuture execute() throws NodeException
When the script has run to completion -- which means that has left no timers or "nextTick" jobs in its queue, and the "http" and "net" modules are no longer listening for incoming network connections, then it will exit with a status code. Cancelling the future will make the script exit more quickly and throw CancellationException. It is also OK to interrupt the script.
NodeExceptionpublic ScriptFuture executeModule() throws NodeException
This method may be used to invoke a module that may, in turn, be driven externally entirely by Java code. Since the script keeps running until the future is cancelled, it is very important that the caller eventually cancel the script, or the thread will leak.
NodeExceptionpublic void close()
public void setSandbox(Sandbox box)
public Sandbox getSandbox()
public Object getAttachment()
public void setAttachment(Object attachment)
public void setPinned(boolean p)
public boolean isPinned()
public void setPrintEval(boolean print)
public boolean isPrintEval()
public Map<String,String> getEnvironment()
public void setEnvironment(Map<String,String> env)
public void setWorkingDirectory(String wd)
public String getWorkingDirectory()
public void setNodeVersion(String v)
public String getNodeVersion()
public void setDisplayName(String dn)
public String getDisplayName()
public void addEnvironment(String name, String value)
public void _setParentProcess(TriremeProcess parent)
public org.mozilla.javascript.Scriptable _getProcessObject()
public void _setChildProcess(boolean child)
public boolean _isChildProcess()
public ScriptRunner _getRuntime()
Copyright © 2016 Apigee Corporation. All Rights Reserved.