public class NodeEnvironment extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
CORE_POOL_SIZE |
static int |
DEFAULT_JS_VERSION |
static String |
DEFAULT_NODE_VERSION
The default version of the Node.js runtime that will be used.
|
static int |
DEFAULT_OPT_LEVEL |
static int |
MAX_POOL_SIZE |
static int |
POOL_QUEUE_SIZE |
static long |
POOL_TIMEOUT_SECS |
| Constructor and Description |
|---|
NodeEnvironment()
Create a new NodeEnvironment with all the defaults.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Free any resources used by the environment.
|
NodeScript |
createScript(String[] args,
boolean forceRepl)
Create an instance of the script that will process command-line arguments from argv like regular
Node.js.
|
NodeScript |
createScript(String scriptName,
File script,
String[] args)
Create an instance of a script attached to this environment.
|
NodeScript |
createScript(String scriptName,
String script,
String[] args)
Create an instance of a script attached to this environment.
|
ExecutorService |
getAsyncPool()
Internal: Get the thread pool for async tasks.
|
ClassCache |
getClassCache() |
org.mozilla.javascript.ContextFactory |
getContextFactory()
Internal: Get the Rhino ContextFactory for this environment.
|
String |
getDefaultNodeVersion()
Return the default implementation version.
|
HttpServerContainer |
getHttpContainer() |
int |
getMaxAsyncPoolSize() |
List<String> |
getNodeVersions()
Return a list of Node.js implementations available in this environment.
|
int |
getOptLevel() |
RootModuleRegistry |
getRegistry(String version)
Internal: Get the registry for a particular implementation
|
Sandbox |
getSandbox() |
ExecutorService |
getScriptPool()
Internal: Get the thread pool for running script threads.
|
long |
getScriptTimeLimit() |
boolean |
isSealRoot()
Deprecated.
|
void |
setClassCache(ClassCache cache)
Set a cache that may be used to store compiled JavaScript classes.
|
void |
setDefaultClassCache()
Create a default instance of the class cache using an internal implementation.
|
void |
setDefaultNodeVersion(String version)
Override the default version.
|
NodeEnvironment |
setHttpContainer(HttpServerContainer container)
Replace the default HTTP implementation with a custom implementation.
|
void |
setMaxAsyncPoolSize(int size)
Set the maximum thread pool size of the "async pool," which will be used for running
short-duration blocking tasks like file I/O, DNS lookups, and some TLS operations.
|
NodeEnvironment |
setOptLevel(int optLevel)
Set the Rhino optimization level for all new scripts that are run.
|
NodeEnvironment |
setSandbox(Sandbox box)
Set up a restricted environment.
|
NodeEnvironment |
setScriptTimeLimit(long limit,
TimeUnit unit)
Set the maximum amount of time that any one "tick" of this script is allowed to execute before an
exception is raised and the script exits.
|
NodeEnvironment |
setSealRoot(boolean sealRoot)
Deprecated.
|
public static final String DEFAULT_NODE_VERSION
public static final int CORE_POOL_SIZE
public static final int MAX_POOL_SIZE
public static final int POOL_QUEUE_SIZE
public static final long POOL_TIMEOUT_SECS
public static final int DEFAULT_JS_VERSION
public static final int DEFAULT_OPT_LEVEL
public NodeEnvironment()
public NodeEnvironment setSandbox(Sandbox box)
public Sandbox getSandbox()
public void close()
public List<String> getNodeVersions()
public String getDefaultNodeVersion()
public void setDefaultNodeVersion(String version)
public NodeScript createScript(String scriptName, File script, String[] args) throws NodeException
Create an instance of a script attached to this environment. Any "setters" that you wish to change for this environment must be called before the first script is run.
When this form of the script is used, all of the arguments will appear on the command line as if they were passed after the name of the script. So, if "foo" and "bar" are passed as arguments, and the script is called "baz.js", then the resulting process.argv will contain, in order:
NodeExceptionpublic NodeScript createScript(String scriptName, String script, String[] args) throws NodeException
Create an instance of a script attached to this environment. Any "setters" that you wish to change for this environment must be called before the first script is run.
When this form of the script is used, all of the arguments will appear on the command line as if they were passed after the name of the script. So, if "foo" and "bar" are passed as arguments, and the script is called "baz.js", then the resulting process.argv will contain, in order:
NodeExceptionpublic NodeScript createScript(String[] args, boolean forceRepl) throws NodeException
Create an instance of the script that will process command-line arguments from argv like regular Node.js. This script will look at process.argv for a script file name, and if not found it will either run the "repl" (if "forceRepl" is true or stdin is not a TTY) or it will read from standard input.
When this form of the script is used, arguments passed before the script name are interpreted by Trireme and not passed to the script, just like regular Node.js. So for instance, if the following list of arguments is passed:
Currently, only a small number of options are supported. They are:
NodeExceptionpublic NodeEnvironment setHttpContainer(HttpServerContainer container)
public HttpServerContainer getHttpContainer()
public int getOptLevel()
public NodeEnvironment setOptLevel(int optLevel)
@Deprecated public boolean isSealRoot()
@Deprecated public NodeEnvironment setSealRoot(boolean sealRoot)
public NodeEnvironment setScriptTimeLimit(long limit, TimeUnit unit)
public long getScriptTimeLimit()
public void setClassCache(ClassCache cache)
public void setDefaultClassCache()
public ClassCache getClassCache()
public void setMaxAsyncPoolSize(int size)
public int getMaxAsyncPoolSize()
public ExecutorService getAsyncPool()
public ExecutorService getScriptPool()
public RootModuleRegistry getRegistry(String version)
public org.mozilla.javascript.ContextFactory getContextFactory()
Copyright © 2016 Apigee Corporation. All Rights Reserved.