org.objectweb.joram.client.jms.pool
Class ConnectionPool

java.lang.Object
  extended by org.objectweb.joram.client.jms.pool.ConnectionPool

public class ConnectionPool
extends java.lang.Object

Implements a pool of connection resulting of a unique ConnectionFactory object. Connections are sorted by identity.


Field Summary
private  java.util.Map<ConnectionKey,java.util.LinkedList<PooledConnection>> cache
          Map containing the lists of connections for each identity
(package private)  int maxFreeConnections
          Maximum number of free connections for an identity in the pool
 
Constructor Summary
ConnectionPool(int maxFreeConnections)
          Creates a new pool of connections.
 
Method Summary
 PooledConnection alloc(java.lang.String name, java.lang.String password)
          Allocates a Connection for the specified identity.
 void free(PooledConnection cnx)
          Frees the specified connection, depending of the number of free connections in the pool this connection is closed or inserted in the pool.
 int getMaxFreeConnections()
          Gets the maximum number of free connections for an identity in the pool.
 void setMaxFreeConnections(int maxFreeConnections)
          Returns the maximum number of free connections for an identity in the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxFreeConnections

int maxFreeConnections
Maximum number of free connections for an identity in the pool


cache

private java.util.Map<ConnectionKey,java.util.LinkedList<PooledConnection>> cache
Map containing the lists of connections for each identity

Constructor Detail

ConnectionPool

public ConnectionPool(int maxFreeConnections)
Creates a new pool of connections.

Parameters:
maxFreeConnections - the maximum number of free connections for an identity in the pool.
Method Detail

getMaxFreeConnections

public int getMaxFreeConnections()
Gets the maximum number of free connections for an identity in the pool.

Returns:
the maxFreeConnections

setMaxFreeConnections

public void setMaxFreeConnections(int maxFreeConnections)
Returns the maximum number of free connections for an identity in the pool.

Parameters:
maxFreeConnections - the maxFreeConnections to set

alloc

public PooledConnection alloc(java.lang.String name,
                              java.lang.String password)
Allocates a Connection for the specified identity.

Parameters:
name - name of user.
password - password of user.
Returns:
A connection for the specified identity.

free

public void free(PooledConnection cnx)
          throws javax.jms.JMSException
Frees the specified connection, depending of the number of free connections in the pool this connection is closed or inserted in the pool.

Parameters:
cnx - The connection to free.
Throws:
javax.jms.JMSException - an error occurs during the cleanup of the connection.


Copyright © 2010 ScalAgent D.T.. All Rights Reserved.