|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectphp.java.script.servlet.EngineFactory
public class EngineFactory
Create JSR 223 script engines from a servlet context.
ContextLoaderListener
,
InvocablePhpServletScriptEngine
,
PhpServletScriptEngine
Field Summary | |
---|---|
static java.lang.String |
ROOT_ENGINE_FACTORY_ATTRIBUTE
The key used to store the factory in the servlet context |
Constructor Summary | |
---|---|
EngineFactory()
Only for internal use |
Method Summary | |
---|---|
static void |
addManaged(javax.servlet.http.HttpServletRequest req,
InvocablePhpServletLocalHttpServerScriptEngine engine)
Manage a script engine |
static java.io.FileReader |
createPhpScriptFileReader(java.io.File phpScriptFile)
Deprecated. Use createPhpScriptFileReader(ScriptFile) instead |
static java.io.FileReader |
createPhpScriptFileReader(php.java.script.servlet.ScriptFile phpScriptFile)
Create a Reader from a given PHP script file. |
static ScriptEngine |
getInvocablePhpScriptEngine(javax.servlet.Servlet servlet,
javax.servlet.ServletContext ctx,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Get a PHP JSR 223 ScriptEngine which implements the Invocable interface from the servlet context. |
static ScriptEngine |
getInvocablePhpScriptEngine(javax.servlet.Servlet servlet,
javax.servlet.ServletContext ctx,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String protocol,
int port)
Get a PHP JSR 223 ScriptEngine, which implements the Invocable interface, from a HTTP server running on the local host. |
static ScriptEngine |
getInvocablePhpScriptEngine(javax.servlet.Servlet servlet,
javax.servlet.ServletContext ctx,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String protocol,
int port,
java.lang.String proxy)
Get a PHP JSR 223 ScriptEngine, which implements the Invocable interface, from a HTTP server running on the local host. |
static php.java.script.servlet.ScriptFile |
getPhpScript(java.lang.String path)
Get a PHP script from the given Path. |
static php.java.script.servlet.ScriptFile |
getPhpScript(java.lang.String path,
java.io.Reader reader)
Get a PHP script from the given Path. |
static ScriptEngine |
getPhpScriptEngine(javax.servlet.Servlet servlet,
javax.servlet.ServletContext ctx,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Get a PHP JSR 223 ScriptEngine from the servlet context. |
void |
releaseScriptEngines(java.util.List list)
Release all managed script engines. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ROOT_ENGINE_FACTORY_ATTRIBUTE
Constructor Detail |
---|
public EngineFactory()
Method Detail |
---|
public static ScriptEngine getPhpScriptEngine(javax.servlet.Servlet servlet, javax.servlet.ServletContext ctx, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws java.lang.Exception
ScriptEngine scriptEngine = EngineFactory.getPhpScriptEngine(this, application, request, response);
scriptEngine.eval(reader);
reader.close();
servlet
- the servletctx
- the servlet contextreq
- the requestres
- the response
PhpServletScriptEngine
java.lang.Exception
java.net.MalformedURLException
java.lang.IllegalStateException
public static ScriptEngine getInvocablePhpScriptEngine(javax.servlet.Servlet servlet, javax.servlet.ServletContext ctx, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws java.lang.Exception
ScriptEngine scriptEngine = EngineFactory.getInvocablePhpScriptEngine(this, application, request, response);
...
scriptEngine.eval(reader);
reader.close ();
Invocable invocableEngine = (Invocable)scriptEngine;
invocableEngine.invoceFunction("phpinfo", new Object[]{});
...
scriptEngine.eval ((Reader)null);
servlet
- the servletctx
- the servlet contextreq
- the requestres
- the response
InvocablePhpServletScriptEngine
java.lang.Exception
java.net.MalformedURLException
java.lang.IllegalStateException
public static ScriptEngine getInvocablePhpScriptEngine(javax.servlet.Servlet servlet, javax.servlet.ServletContext ctx, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.lang.String protocol, int port) throws java.lang.Exception
ScriptEngine scriptEngine = EngineFactory.getInvocablePhpScriptEngine(this, application, request, response, "HTTP", 80);
...
scriptEngine.eval(reader);
reader.close ();
Invocable invocableEngine = (Invocable)scriptEngine;
invocableEngine.invoceFunction("phpinfo", new Object[]{});
...
scriptEngine.eval ((Reader)null);
servlet
- the servletctx
- the servlet contextreq
- the requestres
- the responseprotocol
- either "HTTP" or "HTTPS"port
- the port number
InvocablePhpServletScriptEngine
java.lang.Exception
java.net.MalformedURLException
java.lang.IllegalStateException
public static ScriptEngine getInvocablePhpScriptEngine(javax.servlet.Servlet servlet, javax.servlet.ServletContext ctx, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.lang.String protocol, int port, java.lang.String proxy) throws java.lang.Exception
ScriptEngine scriptEngine = EngineFactory.getInvocablePhpScriptEngine(this, application, request, response, "HTTP", 80);
...
scriptEngine.eval(reader);
reader.close ();
Invocable invocableEngine = (Invocable)scriptEngine;
invocableEngine.invoceFunction("phpinfo", new Object[]{});
...
scriptEngine.eval ((Reader)null);
servlet
- the servletctx
- the servlet contextreq
- the requestres
- the responseprotocol
- either "HTTP" or "HTTPS"port
- the port numberproxy
- the name of the PHP proxy, for example "/JavaProxy.php"
InvocablePhpServletScriptEngine
java.lang.Exception
java.net.MalformedURLException
java.lang.IllegalStateException
public static php.java.script.servlet.ScriptFile getPhpScript(java.lang.String path, java.io.Reader reader)
path
- the file path which should contain the cached script, must be within the web app directoryreader
- the JSR 223 script reader
createPhpScriptFileReader(File)
public static php.java.script.servlet.ScriptFile getPhpScript(java.lang.String path)
path
- the file path which should contain the cached script, must be within the web app directory
createPhpScriptFileReader(File)
public static java.io.FileReader createPhpScriptFileReader(php.java.script.servlet.ScriptFile phpScriptFile)
private static File script;
private static final File getScript() {
if (script!=null) return script;
return EngineFactory.getPhpScript(ctx.getRealPath(req.getServletPath(),new StringReader("<?php phpinfo();?>"));
}
...
FileReader reader = EngineFactory.createPhpScriptFileReader(getScript());
scriptEngine.eval (reader);
reader.close();
...
phpScriptFile
- the file containing the cached script, obtained from getPhpScript(String, Reader)
or getPhpScript(String)
public static java.io.FileReader createPhpScriptFileReader(java.io.File phpScriptFile)
createPhpScriptFileReader(ScriptFile)
instead
phpScriptFile
-
public void releaseScriptEngines(java.util.List list)
list
- the list from the request attribute RequestListener.ROOT_ENGINES_COLLECTION_ATTRIBUTE
public static void addManaged(javax.servlet.http.HttpServletRequest req, InvocablePhpServletLocalHttpServerScriptEngine engine) throws ScriptException
req
- the servlet requestengine
- the engine to manage
ScriptException
releaseScriptEngines(List)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |