public class RequireBuilder
extends java.lang.Object
implements java.io.Serializable
Require instances. Useful when you're creating many instances of Require that are identical except for their top-level scope and current Context. Also
useful if you prefer configuring it using named setters instead of passing many parameters in a
constructor. Every setter returns "this", so you can easily chain their invocations for
additional convenience.| Constructor and Description |
|---|
RequireBuilder() |
| Modifier and Type | Method and Description |
|---|---|
Require |
createRequire(Context cx,
Scriptable globalScope)
Creates a new require() function.
|
RequireBuilder |
setModuleScriptProvider(ModuleScriptProvider moduleScriptProvider)
Sets the
ModuleScriptProvider for the Require instances that this builder
builds. |
RequireBuilder |
setPostExec(Script postExec)
Sets the script that should execute in every module's scope after the module's own script has
executed.
|
RequireBuilder |
setPreExec(Script preExec)
Sets the script that should execute in every module's scope before the module's own script
has executed.
|
RequireBuilder |
setSandboxed(boolean sandboxed)
Sets whether the created require() instances will be sandboxed.
|
public RequireBuilder setModuleScriptProvider(ModuleScriptProvider moduleScriptProvider)
ModuleScriptProvider for the Require instances that this builder
builds.moduleScriptProvider - the module script provider for the Require instances that
this builder builds.public RequireBuilder setPostExec(Script postExec)
postExec - the post-exec script.public RequireBuilder setPreExec(Script preExec)
preExec - the pre-exec script.public RequireBuilder setSandboxed(boolean sandboxed)
Require(Context, Scriptable, ModuleScriptProvider, Script, Script, boolean) for
explanation.sandboxed - true if the created require() instances will be sandboxed.public Require createRequire(Context cx, Scriptable globalScope)
Require.install(Scriptable) or Require.requireMain(Context, String) to effectively
make it available to its JavaScript program.cx - the current contextglobalScope - the global scope containing the JS standard natives.