## php.java.bridge.http
Class ContextFactory

    java.lang.Object
      php.java.bridge.SessionFactory
          php.java.bridge.http.ContextFactory

Direct Known Subclasses:
  ContextFactory, PhpScriptContextFactory

    public class ContextFactory

extends SessionFactory

Create session, jsr223 contexts.

The ContextFactory may keep a promise (a "proxy") which one may evaluate to a session reference (for PHP/JSP session sharing), and/or it may reference a "half-executed" bridge for local channel re-directs (for "high speed" communication links). ContextFactory instances are kept in an array with no more than 65535 entries, after 65535 context creations the context factory is destroyed if this did not happen explicitly. A unique [1..65535] context instance should be created for each request and destroyed when the request is done. The string ID of the instance should be passed to the client, which may pass it back together with the getSession request or the "local channel re-direct". If the former happens, we invoke the promise and return the session object to the client. Different promises can evaluate to the same session object. For local channel re-directs the ContextFactory is given to a ContextRunner which handles the local channel communication.

There can be only one instance of a ContextFactory per classloader.

See Also:
  `ContextFactory`, `ContextServer`

Method Summary
`static ContextFactory` `addNew()` Create a new ContextFactory and add it to the list of context factories kept by this classloader.
`static ContextFactory` `get(java.lang.String id, ContextServer server)` Only for internal use.
`JavaBridge` `getBridge()`
`java.lang.Object` `getContext()` Return the associated context
`java.lang.String` `getId()` Return the serializable ID of the context manager
`void` `remove()` Removes the context factory from the classloader's list of context factories.
`static void` `removeAll()` Remove all context factories from the classloader.
`void` `setBridge(JavaBridge bridge)` Set the JavaBridge into this context.
`java.lang.String` `toString()`
`void` `waitFor()` Wait until this context is finished.

Methods inherited from class php.java.bridge.SessionFactory
`getSession`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Method Detail

### addNew

    public static ContextFactory addNew()

  Create a new ContextFactory and add it to the list of context factories kept by this classloader.

  Returns:
    The created ContextFactory.
  See Also:
    `#get(String)`

### get

    public static ContextFactory get(java.lang.String id,
                                     ContextServer server)

  Only for internal use. Returns the context factory associated with the given `id`

  Parameters:
    `id` - The ID
    `server` - Your context server.
  Returns:
    The ContextFactory or null.
  Throws:
    `java.lang.SecurityException` - if id belongs to a different ContextServer.
  See Also:
    `addNew()`

### remove

    public void remove()

  Removes the context factory from the classloader's list of context factories.

### removeAll

    public static void removeAll()

  Remove all context factories from the classloader. May only be called by the ContextServer.

  See Also:
    `ContextServer`

### waitFor

    public void waitFor()
                 throws java.lang.InterruptedException

  Wait until this context is finished.

  Throws:
    `java.lang.InterruptedException`
  See Also:
    `ContextRunner`

### getId

    public java.lang.String getId()

  Return the serializable ID of the context manager

  Returns:
    The ID

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### getContext

    public java.lang.Object getContext()

  Description copied from class: `SessionFactory`
  Return the associated context

  Overrides:
    `getContext` in class `SessionFactory`
  Returns:
    The context

### setBridge

    public void setBridge(JavaBridge bridge)

  Set the JavaBridge into this context.

  Parameters:
    `bridge` - The bridge to set.

### getBridge

    public JavaBridge getBridge()

  Returns:
    Returns the bridge.