php.java.bridge.http
Interface IContextFactory

All Superinterfaces:
IJavaBridgeFactory
All Known Subinterfaces:
IContextFactoryVisitor
All Known Implementing Classes:
ContextFactory, PhpScriptContextFactory, RemoteServletContextFactory, ServletContextFactory, SimpleContextFactory

public interface IContextFactory
extends IJavaBridgeFactory

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.
 void finishContext()
          Called by recycle() at the end of the script.
 java.lang.ClassLoader getClassLoader()
          Get the class loader from the servlet.
 IContext 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)
          Deprecated. Use recycle(String id) instead.
 void recycle(java.lang.String id)
           Update the context factory with the new JavaBridge obtained from the servlet.
 void recycleLegacy(java.lang.String id)
          Deprecated. Use recycle(String id) instead.
 void removeOrphaned()
          Removes the unused context factory from the classloader's list of context factories.
 void setClassLoader(java.lang.ClassLoader loader)
          Set the class loader obtained from the current servlet into the context.
 void setContext(IContext context)
          Set the Context into this factory.
 void setIsLegacyClient(boolean isLegacyClient)
          Will be called by the PhpJavaServlet and by the JavaBridgeRunner when the client is not the pure PHP client.
 void waitFor()
          Wait until this context is finished.
 void waitFor(long timeout)
          Wait until this context is finished.
 
Methods inherited from interface php.java.bridge.IJavaBridgeFactory
getBridge
 

Method Detail

recycle

void recycle(java.lang.String id)
             throws java.lang.SecurityException

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

Since version 4.1.1 both, the C and the pure PHP implementation pass the context factory via a protocol header. This procedure must obtain the factory for id and pass the bridge to the current context factory. Furthermore it must update the currentThreadContextClassLoader. After the request is done, the ContextFactory#recycle() method is called, which must restore the currentThreadContextClassLoader and the old context factory.

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

recycleLegacy

void recycleLegacy(java.lang.String id)
                   throws java.lang.SecurityException
Deprecated. Use recycle(String id) instead.

Throws:
java.lang.SecurityException

recycle

void recycle(ContextFactory target)
Deprecated. Use recycle(String id) instead.


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

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

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(String)

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

finishContext

void finishContext()
Called by recycle() at the end of the script. Use this method to clean up the instance. for a new child.


setClassLoader

void setClassLoader(java.lang.ClassLoader loader)
Set the class loader obtained from the current servlet into the context.

Parameters:
loader - The currentThreadContextClassLoader

getClassLoader

java.lang.ClassLoader getClassLoader()
Get the class loader from the servlet.

Returns:
The currentThreadContextClassLoader of the servlet.

setIsLegacyClient

void setIsLegacyClient(boolean isLegacyClient)
Will be called by the PhpJavaServlet and by the JavaBridgeRunner when the client is not the pure PHP client.

Parameters:
isLegacyClient -