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
    Modifier and Type
    Field
    Description
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a Rhino evaluator for the given application and request evaluator.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the application we're running in
    static RhinoCore
    Get the RhinoCore instance associated with the current thread, or null
    org.mozilla.javascript.Scriptable
    Get a Script wrapper for any given object.
    org.mozilla.javascript.Scriptable
    Get a node wrapper for a node that may not have been fetched yet
    org.mozilla.javascript.Scriptable
    Get a script wrapper for an instance of helma.objectmodel.INode
    org.mozilla.javascript.Scriptable
    getPrototype(String protoName)
    Get the object prototype for a prototype name and initialize/update it if necessary.
    Get an array containing the property ids of all properties that were compiled from scripts for the given prototype.
    org.mozilla.javascript.Scriptable
    Return the global scope of this RhinoCore.
    org.mozilla.javascript.Scriptable
    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
    Initialize a prototype info without compiling its script files.
    void
    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
     
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • RhinoCore

      public RhinoCore(Application app)
      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

      protected helma.scripting.rhino.RhinoCore.TypeInfo initPrototype(Prototype prototype)
      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 spec
      type - the prototype object info
    • updatePrototypes

      public void updatePrototypes() throws IOException
      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

      public org.mozilla.javascript.Scriptable getValidPrototype(String protoName)
      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

      public org.mozilla.javascript.Scriptable getPrototype(String protoName)
      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

      public Map getPrototypeProperties(String protoName)
      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

      public 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.
    • processXmlRpcArgument

      public Object processXmlRpcArgument(Object arg)
      Convert an input argument from Java to the scripting runtime representation.
    • processXmlRpcResponse

      public Object processXmlRpcResponse(Object arg)
      convert a JavaScript Object object to a generic Java object stucture.
    • getApplication

      public Application getApplication()
      Return the application we're running in
    • getElementWrapper

      public org.mozilla.javascript.Scriptable getElementWrapper(Object e)
      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

      public org.mozilla.javascript.Scriptable getNodeWrapper(INode node)
      Get a script wrapper for an instance of helma.objectmodel.INode
    • getNodeWrapper

      public org.mozilla.javascript.Scriptable getNodeWrapper(NodeHandle handle)
      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
      Throws:
      UnsupportedEncodingException
      IOException
    • getCore

      public static RhinoCore getCore()
      Get the RhinoCore instance associated with the current thread, or null
      Returns:
      the RhinoCore instance associated with the current thread
    • unwrapSkinpath

      protected static Object[] unwrapSkinpath(Object[] skinpath)
    • injectCodeResource

      public void injectCodeResource(String typename, Resource code)
      Add a code resource to a given prototype by immediately compiling and evaluating it.
      Parameters:
      typename - the type this resource belongs to
      code - a code resource
    • getScope

      public org.mozilla.javascript.Scriptable getScope()
      Return the global scope of this RhinoCore.
      Specified by:
      getScope in interface org.mozilla.javascript.tools.debugger.ScopeProvider