public class OS extends Object implements InternalNodeModule
| Modifier and Type | Class and Description |
|---|---|
static class |
OS.OSImpl |
| Constructor and Description |
|---|
OS() |
| Modifier and Type | Method and Description |
|---|---|
String |
getModuleName()
Return the top-level name of the module as it'd be looked up in a "require" call.
|
org.mozilla.javascript.Scriptable |
registerExports(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
NodeRuntime runner)
This is the Java equivalent of a Node module.
|
public String getModuleName()
NodeModulegetModuleName in interface NodeModulepublic org.mozilla.javascript.Scriptable registerExports(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
NodeRuntime runner)
throws InvocationTargetException,
IllegalAccessException,
InstantiationException
NodeModuleThis is the Java equivalent of a Node module. In here, you can set properties on "exports" just as you would set properties on "exports" in a regular Node module. You may also declare any classes using ScriptableObject.defineClass -- by defining them on the "exports" object you may make them private to your module. You may also access and define global properties using "scope." Declare any classes that this module needs, and set any other variables on the exports.
The module must create a Scriptable object using the supplied context, then set any "exports" properties on this object and return it.
For example, a module that in JavaScript would assign several functions to "exports" would create a Scriptable object using "scope" as the parent scope, and then set the various functions as properties.
registerExports in interface NodeModulecx - The Rhino context for the current script and threadscope - The global scope for the scriptrunner - an object that may be used to interact with the script runtimeInvocationTargetExceptionIllegalAccessExceptionInstantiationExceptionCopyright © 2016 Apigee Corporation. All Rights Reserved.