com.sun.emp.cci.eci
Class ECIConnectionManager

java.lang.Object
  |
  +--com.sun.emp.cci.eci.ECIConnectionManager
All Implemented Interfaces:
ConnectionManager, Serializable

public class ECIConnectionManager
extends Object
implements ConnectionManager

A connection manager for ECI connections.

This is the default connection manager for use in unmanaged applications that use the ECI. This class is never used for managed applications.

This connection manager provides support for connection pooling. The use of connection pooling allows the programmer to optimize performance in the sequential usage of connections, as well as allowing the limiting of concurrent resource usage amongst servers.

The connection manager is configured through 2 properties:

Connection pooling can be turned off by setting the maximum pool size to zero.

The configuration of the manager can only be performed before any request for a connection is issued. An attempt to configure it after this time will result in a javax.resource.spi.IllegalStateException being generated.

Debuging of the connection manager is facilitated by the use of the logWriter property.


Constructor Summary
ECIConnectionManager()
          Constructor.
 
Method Summary
 Object allocateConnection(ManagedConnectionFactory mcf, ConnectionRequestInfo cri)
           
 PrintWriter getLogWriter()
          Get the debug destination for this object.
 int getMaxPoolSize()
          Get the maximum size of the connection pool.
 int getPoolTimeout()
          Get the timeout value for connection allocation.
 void setLogWriter(PrintWriter pw)
          Set the debug destination for this object.
 void setMaxPoolSize(int newMaxPoolSize)
          Set the maximum size of the connection pool.
 void setPoolTimeout(int newPoolTimeout)
          Set the timeout value for connection allocation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ECIConnectionManager

public ECIConnectionManager()
Constructor.

Create a connection manager that provides connection pooling with a pool size of 20 and a timeout of 5 seconds.

Method Detail

allocateConnection

public Object allocateConnection(ManagedConnectionFactory mcf,
                                 ConnectionRequestInfo cri)
                          throws ResourceException
Specified by:
allocateConnection in interface ConnectionManager
ResourceException

getMaxPoolSize

public int getMaxPoolSize()
Get the maximum size of the connection pool.

A return value of zero indicates that pooling is not enabled.

Returns:
The maximum pool size.

setMaxPoolSize

public void setMaxPoolSize(int newMaxPoolSize)
                    throws IllegalStateException
Set the maximum size of the connection pool.

A value of zero turns off connection pooling.

Parameters:
newMaxPoolSize - The new maximum pool size.
Throws:
IllegalArgumentException - if the new pool size is not >= 0.
IllegalStateException - if this manager is not allowed further configuration. This situation occurs when the first request for a connection occurs.

getPoolTimeout

public int getPoolTimeout()
Get the timeout value for connection allocation.

Returns:
The timeout in milliseconds - a zero value indicated no timeouts will occur.

setPoolTimeout

public void setPoolTimeout(int newPoolTimeout)
                    throws IllegalStateException
Set the timeout value for connection allocation.

Parameters:
newPoolTimeout - The pool timeout in milliseconds. A value of 0 means there is no timeout.
Throws:
IllegalArgumentException - if the supplied timeout is negative.
IllegalStateException - if this manager is not allowed further configuration. This situation occurs when the first request for a connection occurs.

setLogWriter

public void setLogWriter(PrintWriter pw)
Set the debug destination for this object.

The writer may be null, providing no debug output.

Parameters:
pw - The new debug destination.

getLogWriter

public PrintWriter getLogWriter()
Get the debug destination for this object.

Returns:
The debug destination.