APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.jndi.ldap.pool

pack-priv final Class Connections

extends Object
implements PoolCallback
Class Inheritance
All Implemented Interfaces
com.sun.jndi.ldap.pool.PoolCallback
Imports
java.util.ArrayList, .List, java.util.concurrent.TimeUnit, java.util.concurrent.locks.Condition, .ReentrantLock, java.lang.ref.Reference, .SoftReference, javax.naming.NamingException, .InterruptedNamingException

Represents a list of PooledConnections (actually, ConnectionDescs) with the same pool id. The list starts out with an initial number of connections. Additional PooledConnections are created lazily upon demand. The list has a maximum size. When the number of connections reaches the maximum size, a request for a PooledConnection blocks until a connection is returned to the list. A maximum size of zero means that there is no maximum: connection creation will be attempted when no idle connection is available. The list may also have a preferred size. If the current list size is less than the preferred size, a request for a connection will result in a PooledConnection being created (even if an idle connection is available). If the current list size is greater than the preferred size, a connection being returned to the list will be closed and removed from the list. A preferred size of zero means that there is no preferred size: connections are created only when no idle connection is available and a connection being returned to the list is not closed. Regardless of the preferred size, connection creation always observes the maximum size: a connection won't be created if the list size is at or exceeds the maximum size.
Author
Rosanna Lee

Field Summary

Modifier and TypeField and Description
private boolean
private final Condition
private final List<ConnectionDesc>
private static final boolean
private static final int
private final PooledConnectionFactory
private boolean
private final int
private final ReentrantLock
private final int
private final int
private Reference<Object>
private static final boolean

Constructor Summary

AccessConstructor and Description
pack-priv
Connections(Object
the identity (connection request) of the connections in the list
id
,
int
the number of connections to create initially
initSize
,
int
the preferred size of the pool. The pool will try to maintain a pool of this size by creating and closing connections as needed.
prefSize
,
int
the maximum size of the pool. The pool will not exceed this size. If the pool is at this size, a request for a connection will block until an idle connection is released to the pool or when one is removed.
maxSize
,
PooledConnectionFactory
The factory responsible for creating a connection
factory
,
ReentrantLock lock)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
close()

Called when this instance of Connections has been removed from Pool.

pack-priv PooledConnection
private void
d(String msg, Object o1)

private void
d(String msg, int i)

private void
d(String msg)

pack-priv boolean

Returns:

true if no more connections in list
expire
(long
an entry idle since this time has expired.
threshold
)

Goes through all entries in list, removes and closes ones that have been idle before threshold.

pack-priv PooledConnection
getAvailableConnection(long timeout)

Retrieves an idle connection from this list if one is available.

pack-priv String
pack-priv boolean
grabLock(long timeout)

public boolean
public boolean

Returns:

true if conn removed; false if it was not in pool

public because implemented as part of PoolCallback.

removePooledConnection
(PooledConnection conn)

Implements com.sun.jndi.ldap.pool.PoolCallback.removePooledConnection.

Removes PooledConnection from list of connections.

private void
td(String msg, Object o1, Object o2)

private void
td(String msg, Object o1)

private void
td(String msg)

pack-priv void
pack-priv void
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closedback to summary
private boolean closed
connectionsAvailableback to summary
private final Condition connectionsAvailable
connsback to summary
private final List<ConnectionDesc> conns
debugback to summary
private static final boolean debug
DEFAULT_SIZEback to summary
private static final int DEFAULT_SIZE
factoryback to summary
private final PooledConnectionFactory factory
initializedback to summary
private boolean initialized
initSizeback to summary
private final int initSize
lockback to summary
private final ReentrantLock lock
maxSizeback to summary
private final int maxSize
prefSizeback to summary
private final int prefSize
refback to summary
private Reference<Object> ref
traceback to summary
private static final boolean trace

Constructor Detail

Connectionsback to summary
pack-priv Connections(Object id, int initSize, int prefSize, int maxSize, PooledConnectionFactory factory, ReentrantLock lock) throws NamingException
Parameters
id:Object

the identity (connection request) of the connections in the list

initSize:int

the number of connections to create initially

prefSize:int

the preferred size of the pool. The pool will try to maintain a pool of this size by creating and closing connections as needed.

maxSize:int

the maximum size of the pool. The pool will not exceed this size. If the pool is at this size, a request for a connection will block until an idle connection is released to the pool or when one is removed.

factory:PooledConnectionFactory

The factory responsible for creating a connection

Method Detail

closeback to summary
pack-priv void close()

Called when this instance of Connections has been removed from Pool. This means that no one can get any pooled connections from this Connections any longer. Expire all idle connections as of 'now' and leave indicator so that any in-use connections will be closed upon their return.

createConnectionback to summary
pack-priv PooledConnection createConnection(PooledConnectionFactory factory, long timeout) throws NamingException
dback to summary
private void d(String msg, Object o1)
dback to summary
private void d(String msg, int i)
dback to summary
private void d(String msg)
expireback to summary
pack-priv boolean expire(long threshold)

Goes through all entries in list, removes and closes ones that have been idle before threshold.

Parameters
threshold:long

an entry idle since this time has expired.

Returns:boolean

true if no more connections in list

getAvailableConnectionback to summary
pack-priv PooledConnection getAvailableConnection(long timeout) throws NamingException

Retrieves an idle connection from this list if one is available.

getStatsback to summary
pack-priv String getStats()
grabLockback to summary
pack-priv boolean grabLock(long timeout) throws InterruptedNamingException
releasePooledConnectionback to summary
public boolean releasePooledConnection(PooledConnection conn)

Implements com.sun.jndi.ldap.pool.PoolCallback.releasePooledConnection.

Releases connection back into list. If the list size is below prefSize, the connection may be reused. If the list size exceeds prefSize, then the connection is closed and removed from the list.

public because implemented as part of PoolCallback.

removePooledConnectionback to summary
public boolean removePooledConnection(PooledConnection conn)

Implements com.sun.jndi.ldap.pool.PoolCallback.removePooledConnection.

Removes PooledConnection from list of connections. The closing of the connection is separate from this method. This method is called usually when the caller encounters an error when using the connection and wants it removed from the pool.

Returns:boolean

true if conn removed; false if it was not in pool

public because implemented as part of PoolCallback.

tdback to summary
private void td(String msg, Object o1, Object o2)
tdback to summary
private void td(String msg, Object o1)
tdback to summary
private void td(String msg)
unlockback to summary
pack-priv void unlock()
waitForAvailableConnectionback to summary
pack-priv void waitForAvailableConnection() throws InterruptedNamingException
waitForAvailableConnectionback to summary
pack-priv void waitForAvailableConnection(long waitTime) throws InterruptedNamingException