php.java.bridge.http
Interface IContextFactory

All Known Subinterfaces:
IContextFactoryVisitor
All Known Implementing Classes:
ContextFactory, PhpFacesScriptContextFactory, PhpScriptContextFactory, ServletContextFactory, SimpleContextFactory

public interface IContextFactory

Interface that the ContextFactories must implement.

Author:
jostb

Method Summary
 void destroy()
          Removes the context factory from the classloader's list of context factories and destroys its content.
 JavaBridge getBridge()
          Return the JavaBridge.
 java.lang.Object getContext()
          Return a JSR223 context
 java.lang.String getId()
          Return the serializable ID of the context factory
 ISession getSession(java.lang.String name, boolean clientIsNew, int timeout)
           
 void recycle(ContextFactory target)
          Typically the visitor implements this method, it should attach itself to the target by calling target.accept(this).
 void recycle(java.lang.String id)
          Synchronize the current state with id.
 void removeOrphaned()
          Removes the unused context factory from the classloader's list of context factories.
 void setContext(java.lang.Object context)
          Set the Context into this factory.
 void waitFor()
          Wait until this context is finished.
 

Method Detail

recycle

void recycle(java.lang.String id)
             throws java.lang.SecurityException
Synchronize the current state with id.

When persistent connections are used, the bridge instances recycle their context factories (persistent php clients store their context id, so that they don't have to aquire a new one). However, a client of a php client may have passed a fresh context id. If this happened, the bridge calls this method, which may update the current context with the fresh values from id.

Typically the ContextFactory implements this method. It should find the ContextFactory for id, check that the Factory is not in use (and throw a SecurityException, if isInitialized() returns true), remove it by calling removeOrphaned() and call its recycle() method passing it the current ContextFactory.

Parameters:
id - The fresh id
Throws:
java.lang.NullPointerException - if the current id is not initialized
java.lang.SecurityException - if the found ContextFactory is initialized.
See Also:
recycle(ContextFactory), JavaBridge.recycle()

recycle

void recycle(ContextFactory target)
Typically the visitor implements this method, it should attach itself to the target by calling target.accept(this).

Parameters:
target - The persistent ContextFactory.
See Also:
recycle(String), ContextFactory.accept(IContextFactoryVisitor), IContextFactoryVisitor.visit(ContextFactory), SimpleContextFactory

destroy

void destroy()
Removes the context factory from the classloader's list of context factories and destroys its content.


removeOrphaned

void removeOrphaned()
Removes the unused context factory from the classloader's list of context factories.


waitFor

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

Throws:
java.lang.InterruptedException
See Also:
ContextRunner

getId

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

Returns:
The ID

getContext

java.lang.Object getContext()
Return a JSR223 context

Returns:
The context
See Also:
SimpleContextFactory.getContext(), Context

setContext

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

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

getBridge

JavaBridge getBridge()
Return the JavaBridge.

Returns:
Returns the bridge.

getSession

ISession getSession(java.lang.String name,
                    boolean 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