|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object php.java.script.PhpScriptContextDecorator php.java.script.servlet.PhpHttpScriptContext
public class PhpHttpScriptContext
An example decorator for compiled script engines running in a servlet environment. Use
static final CompiledScript script = ((Compilable)(new ScriptEngineManager().getEngineByName("php-invocable"))).compile("");
script.eval(new php.java.script.servlet.PhpCompiledHttpScriptContext(script.getEngine().getContext(),this,application,request,response));
Field Summary | |
---|---|
static int |
APPLICATION_SCOPE
Integer value for the level of APPLICATION_SCOPE |
static int |
REQUEST_SCOPE
Integer value for the level of SCRIPT_SCOPE |
static int |
SESSION_SCOPE
Integer value for the level of SESSION_SCOPE |
Fields inherited from interface php.java.bridge.http.IContext |
---|
ENGINE_SCOPE, GLOBAL_SCOPE, JAVA_BRIDGE, PHP_PROCEDURE, SERVLET, SERVLET_CONFIG, SERVLET_CONTEXT, SERVLET_REQUEST, SERVLET_RESPONSE |
Fields inherited from interface javax.script.ScriptContext |
---|
ENGINE_SCOPE, GLOBAL_SCOPE |
Constructor Summary | |
---|---|
PhpHttpScriptContext(ScriptContext ctx,
javax.servlet.Servlet servlet,
javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Create a new PhpCompiledScriptContext using an existing PhpScriptContext |
Method Summary | |
---|---|
Continuation |
createContinuation(java.io.Reader reader,
java.util.Map env,
java.io.OutputStream out,
java.io.OutputStream err,
HeaderParser headerParser,
ResultProxy result,
ILogger logger,
boolean isCompiled)
Create a continuation |
java.lang.Object |
getAttribute(java.lang.String name)
Retrieves the value for getAttribute(String, int) for the lowest scope in which it returns a non-null value. |
java.lang.Object |
getAttribute(java.lang.String key,
int scope)
Retrieves the value associated with specified name in the specified level of scope. |
javax.servlet.ServletContext |
getContext()
Get the ServletContext |
ContextServer |
getContextServer()
Get the context server associated with this context, usually a HttpServer (JavaBridgeRunner) or a ContextServer from a ContextLoaderListener |
java.io.Writer |
getErrorWriter()
Returns the Writer used to display error output. |
java.lang.Object |
getHttpServletRequest()
Return the http servlet request |
java.lang.Object |
getHttpServletResponse()
Return the http servlet response |
java.io.Reader |
getReader()
Returns a Reader to be used by the script to read
input. |
java.lang.String |
getRealPath(java.lang.String path)
Get the full file system path for the given resource. |
java.lang.String |
getRedirectString()
Deprecated. |
java.lang.String |
getRedirectString(java.lang.String webPath)
Deprecated. |
java.lang.String |
getRedirectURL(java.lang.String webPath)
Return the redirect string, for example http://localhost:8080/webPath Used by the non-compiling script engines to hard-code the back-end URL in the Java.inc |
javax.servlet.http.HttpServletRequest |
getRequest()
Get the HttpServletRequest |
javax.servlet.http.HttpServletResponse |
getResponse()
Get the servlet response |
java.lang.Object |
getServlet()
Return the http servlet |
java.lang.Object |
getServletConfig()
Return the servlet config |
java.lang.Object |
getServletContext()
Return the servlet context |
java.lang.String |
getSocketName()
Return the socket name, for example 8080 |
java.io.Writer |
getWriter()
Retrieves an instance of java.io.Writer which can be used by scripts to display their output. |
java.lang.Object |
init(java.lang.Object callable)
Initialize a library. |
void |
onShutdown(java.lang.Object closeable)
Register a shutdown hook for the library. |
void |
setAttribute(java.lang.String key,
java.lang.Object value,
int scope)
Sets an attribute specified by the name in specified level of scope. |
void |
setErrorWriter(java.io.Writer errorWriter)
Sets the Writer used to display error output. |
void |
setReader(java.io.Reader reader)
Sets the Reader for scripts to read input
. |
void |
setWriter(java.io.Writer writer)
Sets the Writer for scripts to use when displaying output. |
void |
startContinuation()
Start the current continuation using a context-specific thread pool |
Methods inherited from class php.java.script.PhpScriptContextDecorator |
---|
call, get, getAll, getAttributesScope, getBindings, getContinuation, getScopes, put, putAll, remove, removeAttribute, setBindings, setContinuation |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int REQUEST_SCOPE
public static final int SESSION_SCOPE
public static final int APPLICATION_SCOPE
Constructor Detail |
---|
public PhpHttpScriptContext(ScriptContext ctx, javax.servlet.Servlet servlet, javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
ctx
- the script context to be decoratedMethod Detail |
---|
public Continuation createContinuation(java.io.Reader reader, java.util.Map env, java.io.OutputStream out, java.io.OutputStream err, HeaderParser headerParser, ResultProxy result, ILogger logger, boolean isCompiled)
createContinuation
in interface IPhpScriptContext
createContinuation
in class PhpScriptContextDecorator
reader
- the script readerenv
- the environment passed to phpout
- the fcgi output streamerr
- the fcgi error streamheaderParser
- fcgi header parserresult
- the result proxylogger
- the loggerisCompiled
- create a continuation for a compiled or non-compiled script engine
public void startContinuation()
PhpScriptContextDecorator
startContinuation
in interface IPhpScriptContext
startContinuation
in class PhpScriptContextDecorator
public java.lang.Object getAttribute(java.lang.String key, int scope)
getAttribute
in interface ScriptContext
getAttribute
in interface IContext
getAttribute
in class PhpScriptContextDecorator
key
- the name of the attributescope
- the level of scope
public java.lang.Object getAttribute(java.lang.String name) throws java.lang.IllegalArgumentException
getAttribute
in interface ScriptContext
getAttribute
in interface IContext
getAttribute
in class PhpScriptContextDecorator
name
- the name of the attribute
java.lang.IllegalArgumentException
- if the name is nullpublic void setAttribute(java.lang.String key, java.lang.Object value, int scope) throws java.lang.IllegalArgumentException
setAttribute
in interface ScriptContext
setAttribute
in interface IContext
setAttribute
in class PhpScriptContextDecorator
key
- the name of the attributevalue
- the value of the attributescope
- the level of the scope
java.lang.IllegalArgumentException
- if the name is null scope is
invlaidpublic javax.servlet.http.HttpServletResponse getResponse()
public javax.servlet.http.HttpServletRequest getRequest()
public javax.servlet.ServletContext getContext()
public java.io.Writer getWriter()
getWriter
in interface ScriptContext
getWriter
in interface IContext
getWriter
in class PhpScriptContextDecorator
public void setWriter(java.io.Writer writer)
Writer
for scripts to use when displaying output.
setWriter
in interface ScriptContext
setWriter
in class PhpScriptContextDecorator
writer
- The new Writer
.public java.io.Writer getErrorWriter()
Writer
used to display error output.
getErrorWriter
in interface ScriptContext
getErrorWriter
in class PhpScriptContextDecorator
Writer
public void setErrorWriter(java.io.Writer errorWriter)
Writer
used to display error output.
setErrorWriter
in interface ScriptContext
setErrorWriter
in class PhpScriptContextDecorator
errorWriter
- The Writer
.public java.io.Reader getReader()
Reader
to be used by the script to read
input.
getReader
in interface ScriptContext
getReader
in class PhpScriptContextDecorator
Reader
.public void setReader(java.io.Reader reader)
PhpScriptContextDecorator
Reader
for scripts to read input
.
setReader
in interface ScriptContext
setReader
in class PhpScriptContextDecorator
reader
- The new Reader
.public java.lang.Object init(java.lang.Object callable) throws java.lang.Exception
init
in interface IManaged
init
in class PhpScriptContextDecorator
callable
- Its call() method will be called synchronized.
java.lang.Exception
- The result of the call() invocation.public void onShutdown(java.lang.Object closeable)
onShutdown
in interface IManaged
onShutdown
in class PhpScriptContextDecorator
closeable
- Its close() method will be called before the context or the VM terminates.public java.lang.Object getHttpServletResponse()
getHttpServletResponse
in interface IContext
getHttpServletResponse
in class PhpScriptContextDecorator
public java.lang.Object getHttpServletRequest()
getHttpServletRequest
in interface IContext
getHttpServletRequest
in class PhpScriptContextDecorator
public java.lang.Object getServlet()
getServlet
in interface IContext
getServlet
in class PhpScriptContextDecorator
public java.lang.Object getServletConfig()
getServletConfig
in interface IContext
getServletConfig
in class PhpScriptContextDecorator
public java.lang.Object getServletContext()
getServletContext
in interface IContext
getServletContext
in class PhpScriptContextDecorator
public java.lang.String getRealPath(java.lang.String path)
getRealPath
in interface IContext
getRealPath
in class PhpScriptContextDecorator
path
- the relative path to an existing resource
public java.lang.String getRedirectString(java.lang.String webPath)
getRedirectString
in interface IContext
getRedirectString
in class PhpScriptContextDecorator
public java.lang.String getRedirectString()
getRedirectString
in interface IContext
getRedirectString
in class PhpScriptContextDecorator
public java.lang.String getRedirectURL(java.lang.String webPath)
getRedirectURL
in interface IContext
getRedirectURL
in class PhpScriptContextDecorator
webPath
- Usually request.getContextPath()+request.getServletPath()
public java.lang.String getSocketName()
getSocketName
in interface IContext
getSocketName
in class PhpScriptContextDecorator
public ContextServer getContextServer()
getContextServer
in interface IPhpScriptContext
getContextServer
in class PhpScriptContextDecorator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |