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 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

      public boolean add(E connection)
      Add a connection to this pool.
      Specified by:
      add in interface ConnectionPool<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

      public boolean remove(E connection)
      Remove a connection from this pool.
      Specified by:
      remove in interface ConnectionPool<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

      public E nextConnection()
      Get the next connection.
      Specified by:
      nextConnection in interface ConnectionPool<E extends AutoCloseable>
      Returns:
      a connection.
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: ConnectionPool
      Determine whether this pool is empty.
      Specified by:
      isEmpty in interface ConnectionPool<E extends AutoCloseable>
      Returns:
      true if this pool is empty, false otherwise.
    • connectionCount

      public int connectionCount()
      Description copied from interface: ConnectionPool
      Get the current size of this pool.
      Specified by:
      connectionCount in interface ConnectionPool<E extends AutoCloseable>
      Returns:
      the size as an int.
    • getConnections

      public List<E> getConnections()
      Description copied from interface: ConnectionPool
      Get 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:
      getConnections in interface ConnectionPool<E extends AutoCloseable>
      Returns:
      a list of JPPFClientConnection instances.
    • iterator

      public Iterator<E> iterator()
      Specified by:
      iterator in interface Iterable<E extends AutoCloseable>
    • getSize

      public int getSize()
      Description copied from interface: ConnectionPool
      Get the maximum size of this connection pool.
      Specified by:
      getSize in interface ConnectionPool<E extends AutoCloseable>
      Returns:
      the max size as an int.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • toString

      public String toString()
      Overrides:
      toString in class Object