Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## php.java.servlet.fastcgi
Class ConnectionPool

    java.lang.Object
      php.java.servlet.fastcgi.ConnectionPool

    public class ConnectionPool

extends java.lang.Object

A connection pool. Example:
`ConnectionPool pool = new ConnectionPool("127.0.0.1", 8080, 20, 5000, new ConnectionPool.Factory());
ConnectionPool.Connection conn = pool.openConnection();
InputStream in = conn.getInputStream();
OutputStream out = conn.getOutputStream();
...
in.close();
out.close();
...
pool.destroy();
`

Instead of using delegation (decorator pattern), it is possible to pass a factory which may create custom In- and OutputStreams. Example:
`new ConnectionPool(..., new ConnectionPool.Factory() {
public InputStream getInputStream() {
return new ConnectionPool.DefaultInputStream() {
...
}
}
}
`

Author:
  jostb

Nested Class Summary
`class` | `ConnectionPool.Connection` Represents the connection kept by the pool.

Constructor Summary
`ConnectionPool(ChannelName channelName, int limit, int maxRequests, Factory factory)` Create a new connection pool.

Method Summary
`void` | `destroy()` Destroy the connection pool.
`ConnectionPool.Connection` | `openConnection()` Opens a connection to the back end.

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

Constructor Detail

### ConnectionPool

    public ConnectionPool(ChannelName channelName,
                          int limit,
                          int maxRequests,
                          Factory factory)
                   throws ConnectException

  Create a new connection pool.

  Parameters:
    `limit` - The max. number of physical connections
    `factory` - A factory for creating In- and OutputStreams.
  Throws:
    `ConnectException`
  See Also:
    `Factory`

Method Detail

### openConnection

    public ConnectionPool.Connection openConnection()
                                             throws java.lang.InterruptedException,
                                                    ConnectException,
                                                    java.net.SocketException

  Opens a connection to the back end.

  Returns:
    The connection
  Throws:
    `UnknownHostException`
    `java.lang.InterruptedException`
    `java.net.SocketException`
    `java.io.IOException`
    `ConnectException`

### destroy

    public void destroy()

  Destroy the connection pool. It releases all physical connections.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD