php.java.bridge.http
Interface IContextFactory

All Superinterfaces:
IJavaBridgeFactory
All Known Subinterfaces:
IContextFactoryVisitor
All Known Implementing Classes:
ContextFactory, InteractivePhpScriptContextFactory, PhpScriptContextFactory, RemoteHttpContextFactory, RemoteHttpServletContextFactory, RemoteServletContextFactory, ServletContextFactory, SimpleContextFactory, SimpleServletContextFactory

public interface IContextFactory
extends IJavaBridgeFactory

Interface that the ContextFactories must implement.

Author:
jostb

Method Summary
 IContext getContext()
          Return a 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 initialize()
          Called when the context runner starts
 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 waitFor(long timeout)
          Wait until this context is finished.
 
Methods inherited from interface php.java.bridge.IJavaBridgeFactory
destroy, flushBuffer, getBridge, invalidate, isNew, parseHeader, recycle
 

Method Detail

recycle

void recycle(java.lang.String id)

Update the context factory with the new JavaBridge obtained from the servlet

Parameters:
id - The fresh id
See Also:
ContextFactory.recycle(), Request.setBridge(php.java.bridge.JavaBridge), Request.recycle()

release

void release()
Releases the context factory. This method should be called when the factory is not needed anymore. Implementations could then remove any unused context factory from the classloader's list of context factories.


releaseManaged

void releaseManaged()
                    throws java.lang.InterruptedException
Wait until this context is finished and release/destroy it. This method returns immediately if this context is not in use yet or it is no longer in use. Call this method only if Java has initiated the communication and Java have full control over the connection, for example via a ScriptEngine's URLReader or CGIRunner. For Apache/PHP initiated requests use a combination of #waitFor(long) and #release() instead.

Throws:
java.lang.InterruptedException
See Also:
ContextRunner

waitFor

void waitFor(long timeout)
             throws java.lang.InterruptedException
Wait until this context is finished.

Parameters:
timeout - The timeout
Throws:
java.lang.InterruptedException
See Also:
ContextRunner

getId

java.lang.String getId()
Return the serializable ID of the context factory

Returns:
The ID

getContext

IContext getContext()
Return a JSR223 context

Specified by:
getContext in interface IJavaBridgeFactory
Returns:
The context
See Also:
SimpleContextFactory.getContext(), Context

setContext

void setContext(IContext context)
Set the Context into this factory. Should be called by Context.addNew() only.

Parameters:
context -
See Also:
ContextFactory.addNew()

getSession

ISession getSession(java.lang.String name,
                    short clientIsNew,
                    int timeout)
Description copied from interface: IJavaBridgeFactory
Return a session for the JavaBridge

Specified by:
getSession in interface IJavaBridgeFactory
Parameters:
name - The session name. If name is null, the name PHPSESSION will be used.
clientIsNew - true if the client wants a new session
timeout - timeout in seconds. If 0 the session does not expire.
Returns:
The session
See Also:
ISession

getSimpleSession

ISession getSimpleSession(java.lang.String name,
                          short clientIsNew,
                          int timeout)
Parameters:
name - The session name. If name is null, the name PHPSESSION will be used.
clientIsNew - true if the client wants a new session
timeout - timeout in seconds. If 0 the session does not expire.
Returns:
The session
See Also:
ISession

initialize

void initialize()
Called when the context runner starts

See Also:
releaseManaged(), IJavaBridgeFactory.destroy()