php.java.script
Class InvocablePhpScriptEngine

java.lang.Object
  extended by javax.script.AbstractScriptEngine
      extended by php.java.script.SimplePhpScriptEngine
          extended by php.java.script.InvocablePhpScriptEngine
All Implemented Interfaces:
java.io.Closeable, Invocable, ScriptEngine
Direct Known Subclasses:
InteractivePhpScriptEngine, InvocablePhpServletLocalHttpServerScriptEngine

public class InvocablePhpScriptEngine
extends SimplePhpScriptEngine
implements Invocable

This class implements the ScriptEngine.

Example:

ScriptEngine e = (new ScriptEngineManager()).getEngineByName("php-invocable");
e.eval(<? function f() {return java_server_name();}?>
System.out.println(((Invocable)e).invokeFunction("f", new Object[]{}));
((Closeable)e).close();


Field Summary
 
Fields inherited from interface javax.script.ScriptEngine
ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME
 
Constructor Summary
InvocablePhpScriptEngine()
          Create a new ScriptEngine with a default context.
InvocablePhpScriptEngine(PhpScriptEngineFactory factory)
          Create a new ScriptEngine from a factory.
 
Method Summary
 java.lang.Object getInterface(java.lang.Class clasz)
          Retrieves an instance of java class whose methods are impelemented using procedures in script which are in the intermediate code repository in the underlying interpreter.
 java.lang.Object getInterface(java.lang.Object thiz, java.lang.Class clasz)
          Retrieves an instance of java class whose methods are impelemented using procedures in script which are in the intermediate code repository in the underlying interpreter.
 java.lang.Object invoke(java.lang.Object thiz, java.lang.String methodName, java.lang.Object[] args)
           
 java.lang.Object invoke(java.lang.String methodName, java.lang.Object[] args)
           
 java.lang.Object invokeFunction(java.lang.String methodName, java.lang.Object[] args)
          Invokes a scripting procedure with the given name using the array of objects as its arguments set.
 java.lang.Object invokeMethod(java.lang.Object thiz, java.lang.String methodName, java.lang.Object[] args)
          Invokes a procedure on an object which already defined in the script using the array of objects as its arguments set.
 void release()
          Release the continuation
 
Methods inherited from class php.java.script.SimplePhpScriptEngine
close, createBindings, eval, eval, getFactory
 
Methods inherited from class javax.script.AbstractScriptEngine
eval, eval, eval, eval, get, getBindings, getContext, put, setBindings, setContext
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InvocablePhpScriptEngine

public InvocablePhpScriptEngine()
Create a new ScriptEngine with a default context.


InvocablePhpScriptEngine

public InvocablePhpScriptEngine(PhpScriptEngineFactory factory)
Create a new ScriptEngine from a factory.

Parameters:
factory - The factory
See Also:
SimplePhpScriptEngine.getFactory()
Method Detail

invoke

public java.lang.Object invoke(java.lang.String methodName,
                               java.lang.Object[] args)
                        throws ScriptException,
                               java.lang.NoSuchMethodException
Throws:
ScriptException
java.lang.NoSuchMethodException

invokeFunction

public java.lang.Object invokeFunction(java.lang.String methodName,
                                       java.lang.Object[] args)
                                throws ScriptException,
                                       java.lang.NoSuchMethodException
Description copied from interface: Invocable
Invokes a scripting procedure with the given name using the array of objects as its arguments set.

Specified by:
invokeFunction in interface Invocable
Parameters:
methodName - name of the scripting procedure
args - arguments set for the scripting procedure
Returns:
resultant object after the execution of the procedure
Throws:
ScriptException - if the invocation of the scripting procedure fails
java.lang.NoSuchMethodException

invoke

public java.lang.Object invoke(java.lang.Object thiz,
                               java.lang.String methodName,
                               java.lang.Object[] args)
                        throws ScriptException,
                               java.lang.NoSuchMethodException
Throws:
ScriptException
java.lang.NoSuchMethodException

invokeMethod

public java.lang.Object invokeMethod(java.lang.Object thiz,
                                     java.lang.String methodName,
                                     java.lang.Object[] args)
                              throws ScriptException,
                                     java.lang.NoSuchMethodException
Description copied from interface: Invocable
Invokes a procedure on an object which already defined in the script using the array of objects as its arguments set.

Specified by:
invokeMethod in interface Invocable
Parameters:
thiz - object on which the procedure is called
methodName - name of the procedure to be invoked
args - arguments set for the procedure
Returns:
resultant object after the execution of the procedure
Throws:
ScriptException - if the invocation of the procedure fails
java.lang.NoSuchMethodException

getInterface

public java.lang.Object getInterface(java.lang.Class clasz)
Description copied from interface: Invocable
Retrieves an instance of java class whose methods are impelemented using procedures in script which are in the intermediate code repository in the underlying interpreter.

Specified by:
getInterface in interface Invocable
Parameters:
clasz - an interface which the returned class must implement
Returns:
an instance of the class which implement the specified interface

getInterface

public java.lang.Object getInterface(java.lang.Object thiz,
                                     java.lang.Class clasz)
Description copied from interface: Invocable
Retrieves an instance of java class whose methods are impelemented using procedures in script which are in the intermediate code repository in the underlying interpreter.

Specified by:
getInterface in interface Invocable
Parameters:
thiz - object on which the procedure is called
clasz - an interface which the returned class must implement
Returns:
an instance of the class which implement the specified interface

release

public void release()
Description copied from class: SimplePhpScriptEngine
Release the continuation

Overrides:
release in class SimplePhpScriptEngine