Package helma.scripting.rhino
Class RhinoCore
java.lang.Object
helma.scripting.rhino.RhinoCore
- All Implemented Interfaces:
org.mozilla.javascript.tools.debugger.ScopeProvider
public final class RhinoCore
extends Object
implements org.mozilla.javascript.tools.debugger.ScopeProvider
This is the implementation of ScriptingEnvironment for the Mozilla Rhino EcmaScript interpreter.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRhinoCore
(Application app) Create a Rhino evaluator for the given application and request evaluator. -
Method Summary
Modifier and TypeMethodDescriptionReturn the application we're running instatic RhinoCore
getCore()
Get the RhinoCore instance associated with the current thread, or nullorg.mozilla.javascript.Scriptable
Get a Script wrapper for any given object.org.mozilla.javascript.Scriptable
getNodeWrapper
(NodeHandle handle) Get a node wrapper for a node that may not have been fetched yetorg.mozilla.javascript.Scriptable
getNodeWrapper
(INode node) Get a script wrapper for an instance of helma.objectmodel.INodeorg.mozilla.javascript.Scriptable
getPrototype
(String protoName) Get the object prototype for a prototype name and initialize/update it if necessary.getPrototypeProperties
(String protoName) Get an array containing the property ids of all properties that were compiled from scripts for the given prototype.org.mozilla.javascript.Scriptable
getScope()
Return the global scope of this RhinoCore.org.mozilla.javascript.Scriptable
getValidPrototype
(String protoName) A version of getPrototype() that retrieves a prototype and checks if it is valid, i.e.boolean
hasFunction
(String protoname, String fname) Check if an object has a function property (public method if it is a java object) with that name.protected void
Initialize the evaluator, making sure the minimum type information necessary to bootstrap the rest is parsed.protected helma.scripting.rhino.RhinoCore.TypeInfo
initPrototype
(Prototype prototype) Initialize a prototype info without compiling its script files.void
injectCodeResource
(String typename, Resource code) Add a code resource to a given prototype by immediately compiling and evaluating it.protected String
postProcessHref
(Object obj, String protoName, String href) Convert an input argument from Java to the scripting runtime representation.convert a JavaScript Object object to a generic Java object stucture.protected void
setParentPrototype
(Prototype prototype, helma.scripting.rhino.RhinoCore.TypeInfo type) Set the parent prototype on the ObjectPrototype.void
shutdown()
protected static Object[]
unwrapSkinpath
(Object[] skinpath) void
This method is called before an execution context is entered to let the engine know it should update its prototype information.
-
Field Details
-
app
-
-
Constructor Details
-
RhinoCore
Create a Rhino evaluator for the given application and request evaluator.
-
-
Method Details
-
initialize
protected void initialize()Initialize the evaluator, making sure the minimum type information necessary to bootstrap the rest is parsed. -
shutdown
public void shutdown() -
initPrototype
Initialize a prototype info without compiling its script files.- Parameters:
prototype
- the prototype to be created
-
setParentPrototype
protected void setParentPrototype(Prototype prototype, helma.scripting.rhino.RhinoCore.TypeInfo type) Set the parent prototype on the ObjectPrototype.- Parameters:
prototype
- the prototype spectype
- the prototype object info
-
updatePrototypes
This method is called before an execution context is entered to let the engine know it should update its prototype information. The update policy here is to check for update those prototypes which already have been compiled before. Others will be updated/compiled on demand.- Throws:
IOException
-
getValidPrototype
A version of getPrototype() that retrieves a prototype and checks if it is valid, i.e. there were no errors when compiling it. If invalid, a ScriptingException is thrown. -
getPrototype
Get the object prototype for a prototype name and initialize/update it if necessary. The policy here is to update the prototype only if it hasn't been updated before, otherwise we assume it already was updated by updatePrototypes(), which is called for each request. -
getPrototypeProperties
Get an array containing the property ids of all properties that were compiled from scripts for the given prototype.- Parameters:
protoName
- the name of the prototype- Returns:
- an array containing all compiled properties of the given prototype
-
hasFunction
Check if an object has a function property (public method if it is a java object) with that name. -
processXmlRpcArgument
Convert an input argument from Java to the scripting runtime representation. -
processXmlRpcResponse
convert a JavaScript Object object to a generic Java object stucture. -
getApplication
Return the application we're running in -
getElementWrapper
Get a Script wrapper for any given object. If the object implements the IPathElement interface, the getPrototype method will be used to retrieve the name of the prototype to use. Otherwise, a Java-Class-to-Script-Prototype mapping is consulted. -
getNodeWrapper
Get a script wrapper for an instance of helma.objectmodel.INode -
getNodeWrapper
Get a node wrapper for a node that may not have been fetched yet- Parameters:
handle
- a node handle- Returns:
- a wrapper for the node
-
postProcessHref
protected String postProcessHref(Object obj, String protoName, String href) throws UnsupportedEncodingException, IOException -
getCore
Get the RhinoCore instance associated with the current thread, or null- Returns:
- the RhinoCore instance associated with the current thread
-
unwrapSkinpath
-
injectCodeResource
Add a code resource to a given prototype by immediately compiling and evaluating it.- Parameters:
typename
- the type this resource belongs tocode
- a code resource
-
getScope
public org.mozilla.javascript.Scriptable getScope()Return the global scope of this RhinoCore.- Specified by:
getScope
in interfaceorg.mozilla.javascript.tools.debugger.ScopeProvider
-