|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.script.AbstractScriptEngine
php.java.script.InvocablePhpScriptEngine
public class InvocablePhpScriptEngine
This class implements the ScriptEngine and the Invocable interface.
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();
<?php require_once("java/Java.inc");
function f() {return java_server_name();};
java_call_with_continuation(java_closure());
?>
ScriptEngine e = (new ScriptEngineManager()).getEngineByName("php-invocable");
e.eval(new php.java.script.URLReader(new URL("http://localhost/hello.php")));
System.out.println(((Invocable)e).invokeMethod(e.get("php.java.bridge.PhpProcedure"), "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(Bindings n)
Create a new ScriptEngine with bindings. |
|
InvocablePhpScriptEngine(PhpScriptEngineFactory factory)
Create a new ScriptEngine from a factory. |
|
| Method Summary | |
|---|---|
boolean |
accept(java.io.File outputFile)
|
java.lang.Object |
clone()
|
void |
close()
Release the script engine. |
CompiledScript |
compile(java.io.Reader reader)
Retrieves a CompileScript implementation for the script obtained using java.io.Reader as the script source. |
CompiledScript |
compile(java.lang.String script)
Retrieves a CompileScript implementation for the given piece of script which is a abstraction for the intermediate code produced by the compilation. |
Bindings |
createBindings()
Retrieves an uninitailized namespace which can be used as the scope of the ScriptEngine. |
java.lang.Object |
eval(java.io.Reader reader,
ScriptContext context)
Evaluates a script obtained using the specified reader as the script source and using the namespaces in the specifed ScriptContext. |
java.lang.Object |
eval(java.lang.String script,
ScriptContext context)
Evaluates a script using the namespaces in the specifed ScriptContext. |
ScriptContext |
getContext()
Return the script context. |
ScriptEngineFactory |
getFactory()
Retrieves a ScriptEngineFactory for the class to which describes the underlying ScriptEngine. |
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 |
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 |
void |
setContext(ScriptContext context)
Set a new context. |
| Methods inherited from class javax.script.AbstractScriptEngine |
|---|
eval, eval, eval, eval, get, getBindings, put, setBindings |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.script.ScriptEngine |
|---|
eval, eval, eval, eval, get, getBindings, put, setBindings |
| Constructor Detail |
|---|
public InvocablePhpScriptEngine()
public InvocablePhpScriptEngine(PhpScriptEngineFactory factory)
factory - The factorygetFactory()public InvocablePhpScriptEngine(Bindings n)
n - the bindings| Method Detail |
|---|
public java.lang.Object invokeFunction(java.lang.String methodName,
java.lang.Object[] args)
throws ScriptException,
java.lang.NoSuchMethodException
invokeFunction in interface InvocablemethodName - name of the scripting procedureargs - arguments set for the scripting procedure
ScriptException - if the invocation of the scripting procedure
fails
java.lang.NoSuchMethodException
public java.lang.Object invokeMethod(java.lang.Object thiz,
java.lang.String methodName,
java.lang.Object[] args)
throws ScriptException,
java.lang.NoSuchMethodException
invokeMethod in interface Invocablethiz - object on which the procedure is calledmethodName - name of the procedure to be invokedargs - arguments set for the procedure
ScriptException - if the invocation of the procedure
fails
java.lang.NoSuchMethodExceptionpublic java.lang.Object getInterface(java.lang.Class clasz)
getInterface in interface Invocableclasz - an interface which the returned class must
implement
public java.lang.Object getInterface(java.lang.Object thiz,
java.lang.Class clasz)
getInterface in interface Invocablethiz - object on which the procedure is calledclasz - an interface which the returned class must
implement
public void release()
release in interface IPhpScriptEngine
public java.lang.Object eval(java.io.Reader reader,
ScriptContext context)
throws ScriptException
ScriptEngine
eval in interface ScriptEnginereader - the script sourcecontext - the context contianing different namespace for
script evaluation
ScriptException - if an error occurs
public java.lang.Object eval(java.lang.String script,
ScriptContext context)
throws ScriptException
ScriptEngine
eval in interface ScriptEnginescript - the String representation of the scriptcontext - tbe ScriptContext containing namespaces for the
script evaluation
ScriptException - if an error occurspublic ScriptEngineFactory getFactory()
ScriptEngine
getFactory in interface ScriptEnginepublic Bindings createBindings()
createBindings in interface ScriptEngine
public void close()
throws java.io.IOException
close in interface IPhpScriptEnginejava.io.IOException
public CompiledScript compile(java.lang.String script)
throws ScriptException
compile in interface Compilablescript - the source of the script represented as String
ScriptException - if the compilation fials due to any
reason
public CompiledScript compile(java.io.Reader reader)
throws ScriptException
compile in interface Compilablereader - the reader form which the script source is
obtained
ScriptException - if the compilation fials due to any
reasonpublic ScriptContext getContext()
getContext in interface ScriptEnginegetContext in class AbstractScriptEnginepublic void setContext(ScriptContext context)
setContext in interface ScriptEnginesetContext in class AbstractScriptEnginecontext - The contextpublic boolean accept(java.io.File outputFile)
accept in interface java.io.FileFilterpublic java.lang.Object clone()
clone in interface java.security.cert.CertStoreParametersclone in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||