|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.script.AbstractScriptEngine
php.java.script.PhpScriptEngine
public class PhpScriptEngine
This class implements the ScriptEngine.
Example:
ScriptEngine e = (new ScriptEngineManager()).getEngineByName("php");
e.eval(new URLReader(new URL("http://localhost/foo.php"));
System.out.println(((Invocable)e).invoke("java_get_server_name", new Object[]{}));
e.eval((String)null);
When using an URLReader the external foo.php must contain a call() back into our java continuation at the end of the script:
<?php java_context->call(java_closure()) ?>
And the php.ini must contain a java.servlet setting, so that the bridge selects the servlet- instead of the standalone back-end. Example:
extension=java.so
;;on windows use: extension=php_java.dll
[java]
java.servlet=On
| Field Summary |
|---|
| Fields inherited from interface javax.script.ScriptEngine |
|---|
ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME |
| Constructor Summary | |
|---|---|
PhpScriptEngine()
Create a new ScriptEngine with a default context. |
|
PhpScriptEngine(PhpScriptEngineFactory factory)
Create a new ScriptEngine from a factory. |
|
| Method Summary | |
|---|---|
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. |
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 |
invoke(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. |
java.lang.Object |
invoke(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. |
void |
release()
Release the continuation |
| 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 |
|---|
public PhpScriptEngine()
public PhpScriptEngine(PhpScriptEngineFactory factory)
factory - The factorygetFactory()| Method Detail |
|---|
public java.lang.Object invoke(java.lang.String methodName,
java.lang.Object[] args)
throws ScriptException
Invocable
invoke in interface InvocablemethodName - name of the scripting procedureargs - arguments set for the scripting procedure
ScriptException - if the invocation of the scripting procedure
fails
public java.lang.Object invoke(java.lang.Object thiz,
java.lang.String methodName,
java.lang.Object[] args)
throws ScriptException,
java.lang.RuntimeException
Invocable
invoke 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.RuntimeExceptionpublic java.lang.Object getInterface(java.lang.Class clasz)
Invocable
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)
Invocable
getInterface in interface Invocablethiz - object on which the procedure is calledclasz - an interface which the returned class must
implement
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 void release()
public Bindings createBindings()
createBindings in interface ScriptEngine
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||