Package org.jppf.client
Class AbstractConnectionPool<E extends AutoCloseable>
java.lang.Object
org.jppf.client.AbstractConnectionPool<E>
- Type Parameters:
E- the type of the connections in the pool.
- All Implemented Interfaces:
AutoCloseable,Iterable<E>,ConnectionPool<E>
- Direct Known Subclasses:
AbstractClientConnectionPool
public abstract class AbstractConnectionPool<E extends AutoCloseable>
extends Object
implements ConnectionPool<E>
An abstract implementation of the
ConnectionPool interface.- Since:
- 4.2
- Author:
- Laurent Cohen
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractConnectionPool(int size) Initialize this pool with the specfiied core size. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd a connection to this pool.voidclose()intGet the current size of this pool.Get a list of connections held by this pool.intgetSize()Get the maximum size of this connection pool.booleanisEmpty()Determine whether this pool is empty.iterator()Get the next connection.booleanRemove a connection from this pool.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jppf.client.ConnectionPool
getConnection, setSizeMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
AbstractConnectionPool
protected AbstractConnectionPool(int size) Initialize this pool with the specfiied core size.- Parameters:
size- the minimum number of connections in this pool.
-
-
Method Details
-
add
Add a connection to this pool.- Specified by:
addin interfaceConnectionPool<E extends AutoCloseable>- Parameters:
connection- the connection too add.- Returns:
- true if the underlying list of connections changed as a result of calling this method.
-
remove
Remove a connection from this pool.- Specified by:
removein interfaceConnectionPool<E extends AutoCloseable>- Parameters:
connection- the connection too remove.- Returns:
- true if the underlying list of connections changed as a result of calling this method.
-
nextConnection
Get the next connection.- Specified by:
nextConnectionin interfaceConnectionPool<E extends AutoCloseable>- Returns:
- a connection.
-
isEmpty
public boolean isEmpty()Description copied from interface:ConnectionPoolDetermine whether this pool is empty.- Specified by:
isEmptyin interfaceConnectionPool<E extends AutoCloseable>- Returns:
trueif this pool is empty,falseotherwise.
-
connectionCount
public int connectionCount()Description copied from interface:ConnectionPoolGet the current size of this pool.- Specified by:
connectionCountin interfaceConnectionPool<E extends AutoCloseable>- Returns:
- the size as an int.
-
getConnections
Description copied from interface:ConnectionPoolGet a list of connections held by this pool. The returned list is independent from this pool, thus changing, adding or removing elements has not effect on the pool.- Specified by:
getConnectionsin interfaceConnectionPool<E extends AutoCloseable>- Returns:
- a list of
JPPFClientConnectioninstances.
-
iterator
- Specified by:
iteratorin interfaceIterable<E extends AutoCloseable>
-
getSize
public int getSize()Description copied from interface:ConnectionPoolGet the maximum size of this connection pool.- Specified by:
getSizein interfaceConnectionPool<E extends AutoCloseable>- Returns:
- the max size as an int.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
toString
-