### php.java.servlet

# Class ContextFactory

- `java.lang.Object`

- `php.java.bridge.SessionFactory`

- `php.java.bridge.http.ContextFactory`

- `php.java.servlet.ContextFactory`

Known Direct Subclasses:
  PhpFacesScriptContextFactory

`public class ContextFactory`
`extends ContextFactory`

Manage session contexts for servlets.

In addition to the standard ContextFactory this manager keeps a reference to the HttpServletRequest.

See Also:
  `ContextFactory`, `ContextServer`

## Method Summary

`static ContextFactory`

`addNew(javax.servlet.ServletContext kontext, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)`
  Create and add a new ContextFactory.

`ISession`

`getSession(java.lang.String name, boolean clientIsNew, int timeout)`

`void`

`remove()`

`void`

`setSession(javax.servlet.http.HttpServletRequest req)`
  Set the HttpServletRequest for session sharing.

`java.lang.String`

`toString()`

### Methods inherited from class php.java.bridge.http.ContextFactory

`addNew`, `get`, `getBridge`, `getContext`, `getId`, `remove`, `removeAll`, `setBridge`, `toString`, `waitFor`

### Methods inherited from class php.java.bridge.SessionFactory

`getContext`, `getSession`

### Methods inherited from class java.lang.Object

`equals`, `getClass`, `hashCode`, `notify`, `notifyAll`, `toString`, `wait`, `wait`, `wait`

## Method Details

### addNew

    public static ContextFactory addNew(javax.servlet.ServletContext kontext,
                                        javax.servlet.http.HttpServletRequest req,
                                        javax.servlet.http.HttpServletResponse res)

> Create and add a new ContextFactory.

> Parameters:
>   `req` - The HttpServletRequest
>   `res` - The HttpServletResponse

> Returns:
>   The created ContextFactory

### getSession

    public ISession getSession(java.lang.String name,
                               boolean clientIsNew,
                               int timeout)

> Overrides:
>   getSession in interface SessionFactory

### remove

    public void remove()

> Overrides:
>   remove in interface ContextFactory

### setSession

    public void setSession(javax.servlet.http.HttpServletRequest req)

> Set the HttpServletRequest for session sharing.

> Parameters:
>   `req` - The HttpServletRequest

> Throws:
>   `java.lang.IllegalStateException` - When the ContextFactory was created with a HttpServletRequest or when this method was called twice.

### toString

    public java.lang.String toString()

> Overrides:
>   toString in interface ContextFactory