|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectphp.java.script.servlet.EngineFactory
public final 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()
Create a new EngineFactory |
|
| Method Summary | |
|---|---|
static java.io.FileReader |
createPhpScriptFileReader(java.io.File phpScriptFile)
Use createPhpScriptFileReader(ScriptFile) instead |
static java.io.FileReader |
createPhpScriptFileReader(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 ScriptEngine |
getInvocablePhpScriptEngine(javax.servlet.Servlet servlet,
javax.servlet.ServletContext ctx,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.net.URI uri)
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.net.URI uri,
java.lang.String localName)
Get a PHP JSR 223 ScriptEngine, which implements the Invocable interface, from a HTTP server running on the local host. |
static ScriptFile |
getPhpScript(java.lang.String path)
Get a PHP script from the given Path. |
static ScriptFile |
getPhpScript(java.lang.String path,
java.io.Reader reader)
Get a PHP script from the given Path. |
static ScriptFile |
getPhpScript(java.lang.String webPath,
java.lang.String path)
Get a PHP script from the given Path. |
static ScriptFile |
getPhpScript(java.lang.String webPath,
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. |
static java.lang.String |
getRealPath(javax.servlet.ServletContext ctx,
java.lang.String path)
Wrapper for ServletContext.getRealPath(String), throws an IllegalArgumentException if the path could not be determined. |
void |
releaseScriptEngines(java.util.List list)
Only for internal use. |
| 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
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
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
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"
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.net.URI uri,
java.lang.String localName)
throws java.lang.Exception
ScriptEngine scriptEngine = EngineFactory.getInvocablePhpScriptEngine(this, application, request, response, new URI("http://remoteHostName:80/JavaBridge/java/JavaProxy.php"), "thisHostName");
...
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 responseuri - the URI of the remote PHP script engine. The localName is used by the remote script engine to connect back to the current host.localName - the official STATIC(!) server name or ip address of this host (in case there's an IP based load balancer in between).
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.net.URI uri)
throws java.lang.Exception
ScriptEngine scriptEngine = EngineFactory.getInvocablePhpScriptEngine(this, application, request, response, new URI("http://127.0.0.1:80/JavaBridge/java/JavaProxy.php"));
...
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 responseuri - the URI of the remote PHP script engine, there must not be an IP-based load balancer in between
java.lang.Exception
java.net.MalformedURLException
java.lang.IllegalStateException
public static 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 ScriptFile getPhpScript(java.lang.String webPath,
java.lang.String path,
java.io.Reader reader)
webPath - the web path of the script or the web path of a resource within the current contextpath - the file path which should contain the cached scriptreader - the JSR 223 script reader
createPhpScriptFileReader(File)public static 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 ScriptFile getPhpScript(java.lang.String webPath,
java.lang.String path)
webPath - the web path of the script or the web path of a resource within the current contextpath - the file path which should contain the cached script
createPhpScriptFileReader(File)
public static java.lang.String getRealPath(javax.servlet.ServletContext ctx,
java.lang.String path)
ServletContext.getRealPath(String), throws an IllegalArgumentException if the path could not be determined.
ctx - ServletContextpath - the resource path
public static java.io.FileReader createPhpScriptFileReader(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 of script engines
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||