|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectphp.java.bridge.JavaBridgeFactory
php.java.servlet.RemoteHttpServletContextFactory
public class RemoteHttpServletContextFactory
Create session contexts for servlets.
This ContextFactory can be used in environments where no custom class loaders and no threads are allowed.
ContextFactory,
ContextServer,
Serialized Form| Field Summary | |
|---|---|
static java.lang.String |
CONTEXT_FACTORY_ATTRIBUTE
|
| Constructor Summary | |
|---|---|
RemoteHttpServletContextFactory(javax.servlet.Servlet servlet,
javax.servlet.ServletContext ctx,
javax.servlet.http.HttpServletRequest proxy,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
|
|
| Method Summary | |
|---|---|
static IContextFactory |
addNew(javax.servlet.Servlet servlet,
javax.servlet.ServletContext kontext,
javax.servlet.http.HttpServletRequest proxy,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
IContextFactoryVisitor impl)
Create and add a new ContextFactory. |
void |
destroy()
Destroy the factory |
void |
flushBuffer()
Flush the response buffer |
IContext |
getContext()
Return the associated JSR223 context |
java.lang.String |
getId()
Return the serializable ID of the context factory |
ISession |
getSession(java.lang.String name,
short clientIsNew,
int timeout)
Return a session for the JavaBridge |
ISession |
getSimpleSession(java.lang.String name,
short clientIsNew,
int timeout)
|
void |
handleRequests(java.io.InputStream in,
java.io.OutputStream out)
Handle requests from the InputStream, write the responses to OutputStream |
void |
initialize()
Called when the context runner starts |
void |
invalidate()
Hook is called at the end of the life cycle. |
void |
parseHeader(Request req,
java.io.InputStream in)
Called for the request header |
void |
recycle(java.lang.String id)
Update the context factory with the new JavaBridge obtained from the servlet |
void |
release()
Releases the context factory. |
void |
releaseManaged()
Wait until this context is finished and release/destroy it. |
void |
setContext(IContext context)
Set the Context into this factory. |
void |
setResponse(javax.servlet.http.HttpServletResponse out)
Set the current response |
void |
waitFor(long timeout)
Wait until this context is finished. |
| Methods inherited from class php.java.bridge.JavaBridgeFactory |
|---|
getBridge, isNew, recycle |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface php.java.bridge.IJavaBridgeFactory |
|---|
getBridge, isNew, recycle |
| Field Detail |
|---|
public static final java.lang.String CONTEXT_FACTORY_ATTRIBUTE
| Constructor Detail |
|---|
public RemoteHttpServletContextFactory(javax.servlet.Servlet servlet,
javax.servlet.ServletContext ctx,
javax.servlet.http.HttpServletRequest proxy,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
| Method Detail |
|---|
public static IContextFactory addNew(javax.servlet.Servlet servlet,
javax.servlet.ServletContext kontext,
javax.servlet.http.HttpServletRequest proxy,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
IContextFactoryVisitor impl)
servlet - The servletkontext - The servlet contextproxy - The request proxyreq - The HttpServletRequestres - The HttpServletResponse
public java.lang.String getId()
getId in interface IContextFactory
public ISession getSimpleSession(java.lang.String name,
short clientIsNew,
int timeout)
getSimpleSession in interface IContextFactoryname - The session name. If name is null, the name PHPSESSION will be used.clientIsNew - true if the client wants a new sessiontimeout - timeout in seconds. If 0 the session does not expire.
ISession
public ISession getSession(java.lang.String name,
short clientIsNew,
int timeout)
getSession in interface IContextFactorygetSession in interface IJavaBridgeFactorygetSession in class JavaBridgeFactoryname - The session name. If name is null, the name PHPSESSION will be used.clientIsNew - one of ISession.SESSION_CREATE_NEW ISession.SESSION_GET_OR_CREATE or ISession.SESSION_GETtimeout - timeout in seconds. If 0 the session does not expire.
ISessionpublic void initialize()
initialize in interface IContextFactoryIContextFactory.releaseManaged(),
IJavaBridgeFactory.destroy()public void invalidate()
invalidate in interface IJavaBridgeFactoryIJavaBridgeFactory.destroy(),
IJavaBridgeFactory.recycle()public void recycle(java.lang.String id)
Update the context factory with the new JavaBridge obtained from the servlet
recycle in interface IContextFactoryid - The fresh idContextFactory.recycle(),
Request.setBridge(php.java.bridge.JavaBridge),
Request.recycle()public void release()
release in interface IContextFactory
public void releaseManaged()
throws java.lang.InterruptedException
releaseManaged in interface IContextFactoryjava.lang.InterruptedExceptionContextRunner
public void waitFor(long timeout)
throws java.lang.InterruptedException
waitFor in interface IContextFactorytimeout - The timeout
java.lang.InterruptedExceptionContextRunner
public void parseHeader(Request req,
java.io.InputStream in)
throws java.io.IOException
parseHeader in interface IJavaBridgeFactoryparseHeader in class JavaBridgeFactoryreq - the current requestin - the input stream
java.io.IOExceptionpublic void setContext(IContext context)
setContext in interface IContextFactoryContextFactory.addNew()public IContext getContext()
getContext in interface IContextFactorygetContext in interface IJavaBridgeFactorygetContext in class JavaBridgeFactoryContextFactory.getContext()public void destroy()
destroy in interface IJavaBridgeFactorydestroy in class JavaBridgeFactory
public void flushBuffer()
throws java.io.IOException
flushBuffer in interface IJavaBridgeFactoryjava.io.IOExceptionpublic void setResponse(javax.servlet.http.HttpServletResponse out)
out - the PhpJavaServlet response
public void handleRequests(java.io.InputStream in,
java.io.OutputStream out)
throws java.io.IOException
in - the InputStreamout - the OutputStream
java.io.IOException - Example:
protected void doPut (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
IContextFactory ctx = new RemoteHttpServletContextFactory(this, getServletContext(), req, req, res);
res.setHeader("X_JAVABRIDGE_CONTEXT", ctx.getId());
res.setHeader("Pragma", "no-cache");
res.setHeader("Cache-Control", "no-cache");
try { ctx.handleRequests(req.getInputStream(), res.getOutputStream()); } finally { ctx.destroy(); }
}
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||