helma.scripting
Interface ScriptingEngine

All Known Implementing Classes:
RhinoEngine

public interface ScriptingEngine

This is the interface that must be implemented to make a scripting environment usable by the Helma application server. Implementations of this interface must have a public zero-argument constructor to be usable by the Helma framework.


Field Summary
static int ARGS_WRAP_DEFAULT
          Argument wrapping mode that indicates arguments may be arbitrary Java objects that may need to be wrapped.
static int ARGS_WRAP_NONE
          Argument wrapping mode that indicates arguments are wrapped already and should be passed along unchanged.
static int ARGS_WRAP_XMLRPC
          Argument wrapping mode that indicates this is an XML-RPC call and arguments should be processed accordingly.
 
Method Summary
 void abort()
          Let the evaluator know that the current evaluation has been aborted.
 java.lang.Object deserialize(java.io.InputStream in)
          Provide object deserialization for this engine's scripted objects.
 void enterContext()
          This method is called when an execution context for a request evaluation is entered to let the Engine know it should update its prototype information
 void exitContext()
          This method is called to let the scripting engine know that the current execution context has terminated.
 DocApplication getDoc()
          Get an IPathElement that offers introspection services into the application.
 java.lang.Object getProperty(java.lang.Object thisObject, java.lang.String propertyName)
          Get a property on an object
 boolean hasFunction(java.lang.Object thisObject, java.lang.String functionName, boolean resolve)
          Return true if a function by that name is defined for that object.
 boolean hasProperty(java.lang.Object thisObject, java.lang.String propertyName)
          Return true if a property by that name is defined for that object.
 void init(Application app, RequestEvaluator reval)
          Init the scripting engine with an application and a request evaluator
 void injectCodeResource(java.lang.String typename, Resource resource)
          Add a code resource to a given prototype by immediately compiling and evaluating it.
 java.lang.Object invoke(java.lang.Object thisObject, java.lang.Object function, java.lang.Object[] args, int argsWrapMode, boolean resolve)
          Invoke a function on some object, using the given arguments and global vars.
 boolean isTypedObject(java.lang.Object obj)
          Determine if the given object is mapped to a type of the scripting engine
 void serialize(java.lang.Object obj, java.io.OutputStream out)
          Provide object serialization for this engine's scripted objects.
 void setGlobals(java.util.Map globals)
          This method is called when an execution context for a request evaluation is entered.
 void shutdown()
          Shut down the Scripting engine.
 java.lang.String toString(java.lang.Object obj)
          Return a string representation for the given object
 

Field Detail

ARGS_WRAP_NONE

static final int ARGS_WRAP_NONE
Argument wrapping mode that indicates arguments are wrapped already and should be passed along unchanged.

See Also:
Constant Field Values

ARGS_WRAP_DEFAULT

static final int ARGS_WRAP_DEFAULT
Argument wrapping mode that indicates arguments may be arbitrary Java objects that may need to be wrapped.

See Also:
Constant Field Values

ARGS_WRAP_XMLRPC

static final int ARGS_WRAP_XMLRPC
Argument wrapping mode that indicates this is an XML-RPC call and arguments should be processed accordingly.

See Also:
Constant Field Values
Method Detail

init

void init(Application app,
          RequestEvaluator reval)
Init the scripting engine with an application and a request evaluator

Parameters:
app - the application
reval - the request evaluator

shutdown

void shutdown()
Shut down the Scripting engine.


enterContext

void enterContext()
                  throws java.io.IOException,
                         ScriptingException
This method is called when an execution context for a request evaluation is entered to let the Engine know it should update its prototype information

Throws:
java.io.IOException - an I/O exception occurred
ScriptingException - a script related exception occurred

setGlobals

void setGlobals(java.util.Map globals)
                throws ScriptingException
This method is called when an execution context for a request evaluation is entered. The globals parameter contains the global values to be applied during this execution context.

Parameters:
globals - map of global variables
Throws:
ScriptingException - a script related exception occurred

exitContext

void exitContext()
This method is called to let the scripting engine know that the current execution context has terminated.


invoke

java.lang.Object invoke(java.lang.Object thisObject,
                        java.lang.Object function,
                        java.lang.Object[] args,
                        int argsWrapMode,
                        boolean resolve)
                        throws ScriptingException
Invoke a function on some object, using the given arguments and global vars. XML-RPC calls require special input and output parameter conversion.

Parameters:
thisObject - the object to invoke the function on, or null for global functions
function - the name of the function to be invoked
args - array of argument objects
argsWrapMode - indicated the way to process the arguments. Must be one of ARGS_WRAP_NONE, ARGS_WRAP_DEFAULT, ARGS_WRAP_XMLRPC
resolve - indicates whether functionName may contain an object path or just the plain function name
Returns:
the return value of the function
Throws:
ScriptingException - to indicate something went wrong with the invocation

abort

void abort()
Let the evaluator know that the current evaluation has been aborted.


getProperty

java.lang.Object getProperty(java.lang.Object thisObject,
                             java.lang.String propertyName)
Get a property on an object

Parameters:
thisObject - the object
propertyName - the property name
Returns:
true the property value, or null

hasFunction

boolean hasFunction(java.lang.Object thisObject,
                    java.lang.String functionName,
                    boolean resolve)
Return true if a function by that name is defined for that object.

Parameters:
thisObject - the object
functionName - the function name
resolve - if member path in function name should be resolved
Returns:
true if the function is defined on the object

hasProperty

boolean hasProperty(java.lang.Object thisObject,
                    java.lang.String propertyName)
Return true if a property by that name is defined for that object.

Parameters:
thisObject - the object
propertyName - the property name
Returns:
true if the function is defined on the object

isTypedObject

boolean isTypedObject(java.lang.Object obj)
Determine if the given object is mapped to a type of the scripting engine

Parameters:
obj - an object
Returns:
true if the object is mapped to a type

toString

java.lang.String toString(java.lang.Object obj)
Return a string representation for the given object

Parameters:
obj - an object
Returns:
a string representing the object

getDoc

DocApplication getDoc()
Get an IPathElement that offers introspection services into the application. If this method returns null, no introspection is available for this kind of engine. In order to be compatible with the standard Helma management application, this class should be compatible with helma.doc.DocApplication.


serialize

void serialize(java.lang.Object obj,
               java.io.OutputStream out)
               throws java.io.IOException
Provide object serialization for this engine's scripted objects. If no special provisions are required, this method should just wrap the stream with an ObjectOutputStream and write the object.

Parameters:
obj - the object to serialize
out - the stream to write to
Throws:
java.io.IOException

deserialize

java.lang.Object deserialize(java.io.InputStream in)
                             throws java.io.IOException,
                                    java.lang.ClassNotFoundException
Provide object deserialization for this engine's scripted objects. If no special provisions are required, this method should just wrap the stream with an ObjectIntputStream and read the object.

Parameters:
in - the stream to read from
Returns:
the deserialized object
Throws:
java.io.IOException
java.lang.ClassNotFoundException

injectCodeResource

void injectCodeResource(java.lang.String typename,
                        Resource resource)
Add a code resource to a given prototype by immediately compiling and evaluating it.

Parameters:
typename - the type this resource belongs to
resource - a code resource


Copyright © 1998-1998-${year} Helma.org. All Rights Reserved.