public class RhinoSandboxImpl extends Object implements RhinoSandbox
| Constructor and Description |
|---|
RhinoSandboxImpl() |
| Modifier and Type | Method and Description |
|---|---|
RhinoSandbox |
allow(Class<?> clazz)
Will allow access to this class in Rhino scripts.
|
void |
assertContextFactory()
see https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scopes_and_Contexts
|
void |
assertSafeScope(org.mozilla.javascript.Context context) |
Object |
eval(String sourceName,
String js)
Evaluate a script with its own scope.
|
Object |
eval(String sourceName,
String js,
Map<String,Object> variables)
Evaluate a script with its own scope.
|
Object |
evalWithGlobalScope(String sourceName,
String js)
Evaluate the given script with the global scope.
|
RhinoSandbox |
inject(Class<org.mozilla.javascript.ScriptableObject> clazz)
Will make this class available to instantiate in Rhino scripts.
|
RhinoSandbox |
inject(String variableName,
Object object)
Will add a global variable available to all scripts executed with this sandbox.
|
RhinoSandbox |
setInstructionLimit(int limit)
Sets the maximum instructions allowed for script execution.
|
RhinoSandbox |
setMaxDuration(int limitInMs)
Sets the maximum allowed duration for scripts.
|
RhinoSandbox |
setUseSafeStandardObjects(boolean useSafeStandardObjects)
If .initSafeStandardObjects should be used.
|
RhinoSandbox |
setUseSealedScope(boolean value)
If the global scope should be sealed (default: true).
|
public void assertContextFactory()
public void assertSafeScope(org.mozilla.javascript.Context context)
public Object evalWithGlobalScope(String sourceName, String js)
RhinoSandboxevalWithGlobalScope in interface RhinoSandboxpublic Object eval(String sourceName, String js, Map<String,Object> variables)
RhinoSandboxEvaluate a script with its own scope. It has access to all objects in the global scope but cannot add new ones.
variables defines variables with Java objects which will be available for the execution of this script.
eval in interface RhinoSandboxpublic Object eval(String sourceName, String js)
RhinoSandboxeval in interface RhinoSandboxpublic RhinoSandbox setInstructionLimit(int limit)
RhinoSandboxsetInstructionLimit in interface RhinoSandboxpublic RhinoSandbox setMaxDuration(int limitInMs)
setMaxDuration in interface RhinoSandboxpublic RhinoSandbox setUseSafeStandardObjects(boolean useSafeStandardObjects)
RhinoSandboxsetUseSafeStandardObjects in interface RhinoSandboxpublic RhinoSandbox allow(Class<?> clazz)
RhinoSandboxWill allow access to this class in Rhino scripts.
Note that for classes in packages which don't start with java., com., net. etc. the class name needs to be prefixed with Packages.
e.g. mypackage.Myclass will be Packages.mypackage.MyClass
allow in interface RhinoSandboxpublic RhinoSandbox inject(Class<org.mozilla.javascript.ScriptableObject> clazz)
RhinoSandboxinject in interface RhinoSandboxpublic RhinoSandbox inject(String variableName, Object object)
RhinoSandboxinject in interface RhinoSandboxpublic RhinoSandbox setUseSealedScope(boolean value)
RhinoSandboxsetUseSealedScope in interface RhinoSandboxCopyright © 2018. All rights reserved.