|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object php.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 FormField 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 IContextFactory
name
- 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 IContextFactory
getSession
in interface IJavaBridgeFactory
getSession
in class JavaBridgeFactory
name
- 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_GET
timeout
- timeout in seconds. If 0 the session does not expire.
ISession
public void initialize()
initialize
in interface IContextFactory
IContextFactory.releaseManaged()
,
IJavaBridgeFactory.destroy()
public void invalidate()
invalidate
in interface IJavaBridgeFactory
IJavaBridgeFactory.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 IContextFactory
id
- 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 IContextFactory
java.lang.InterruptedException
ContextRunner
public void waitFor(long timeout) throws java.lang.InterruptedException
waitFor
in interface IContextFactory
timeout
- The timeout
java.lang.InterruptedException
ContextRunner
public void parseHeader(Request req, java.io.InputStream in) throws java.io.IOException
parseHeader
in interface IJavaBridgeFactory
parseHeader
in class JavaBridgeFactory
req
- the current requestin
- the input stream
java.io.IOException
public void setContext(IContext context)
setContext
in interface IContextFactory
ContextFactory.addNew()
public IContext getContext()
getContext
in interface IContextFactory
getContext
in interface IJavaBridgeFactory
getContext
in class JavaBridgeFactory
ContextFactory.getContext()
public void destroy()
destroy
in interface IJavaBridgeFactory
destroy
in class JavaBridgeFactory
public void flushBuffer() throws java.io.IOException
flushBuffer
in interface IJavaBridgeFactory
java.io.IOException
public void setResponse(javax.servlet.http.HttpServletResponse out)
out
- the PhpJavaServlet responsepublic 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 |