|
||||||||||
| 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
php.java.script.servlet.InvocablePhpServletScriptEngine
public class InvocablePhpServletScriptEngine
A PHP script engine which implements the Invocable interface for Servlets. See ContextLoaderListener for details.
PHP scripts are evaluated as follows:
EngineFactory:
private static File script;
private static final File getScriptF() {
if (script!=null) return script;
String webCacheDir = ctx.getRealPath(req.getServletPath());
Reader reader = new StringReader ("<?php function f($v) {return "passed:".$v;} ?>");
return EngineFactory.getPhpScript(webCacheDir, reader);
}
EngineFactory:
ScriptEngine scriptEngine = EngineFactory.getInvocablePhpScriptEngine(this, ctx, req, res);
Reader readerF = EngineFactory.createPhpScriptFileReader(getScriptF());
scriptEngine.eval(readerF);
EngineFactory:
readerF.close();
Invocable invocableEngine = (Invocable)scriptEngine;
System.out.println("result from PHP:" + invocableEngine.invoceFunction(f, new Object[]{"arg1"}));
scriptEngine.eval((Reader)null);
ScriptEngine e = EngineFactory.getInvocablePhpScriptEngine(this, ctx, req, res);
e.eval("<?php function f($v) {return "passed:".$v;} ?>");
((Invocable)e).invoceFunction("f", new Object[]{"arg1"};
e.eval((Reader)null);
| Field Summary |
|---|
| Fields inherited from interface javax.script.ScriptEngine |
|---|
ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME |
| Constructor Summary | |
|---|---|
InvocablePhpServletScriptEngine(javax.servlet.Servlet servlet,
javax.servlet.ServletContext ctx,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
|
|
| 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. |
void |
release()
Release the continuation |
| Methods inherited from class php.java.script.InvocablePhpScriptEngine |
|---|
getInterface, getInterface, invoke, invoke, invokeFunction, invokeMethod |
| 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 InvocablePhpServletScriptEngine(javax.servlet.Servlet servlet,
javax.servlet.ServletContext ctx,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws java.net.MalformedURLException,
java.net.URISyntaxException
java.net.MalformedURLException
java.net.URISyntaxException| Method Detail |
|---|
public void release()
release in class InvocablePhpScriptEngine
public java.lang.Object eval(java.io.Reader reader,
ScriptContext context)
throws ScriptException
ScriptEngine
reader - 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
script - the String representation of the scriptcontext - tbe ScriptContext containing namespaces for the
script evaluation
ScriptException - if an error occurspublic ScriptEngineFactory getFactory()
ScriptEngine
public Bindings createBindings()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||