## 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

Manage session contexts.

The context may a) keep a promise (a "proxy") which one may evaluate to a session reference (for PHP/JSP session sharing), and/or b) it may reference a "half-executed" bridge for local channel re-directs (for "high speed" communication links). Context instances are kept in an array with no more than 65535 entries, after 65535 context creations the context 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 Context is given to a ContextRunner, which handles the local channel communication.

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

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 VM.
`static ContextFactory` `get(java.lang.String id)` Returns the context factory associated with the given `id`
`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 VM list of context factories.
`static void` `removeAll()` Remove all context factories from the VM.
`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 VM.

  Returns:
    The created ContextFactory.

### get

    public static ContextFactory get(java.lang.String id)

  Returns the context factory associated with the given `id`

  Parameters:
    `id` - The ID
  Returns:
    The ContextFactory or null.

### remove

    public void remove()

  Removes the context factory from the VM list of context factories.

### removeAll

    public static void removeAll()

  Remove all context factories from the VM. 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.