Class Pool<T>

java.lang.Object
com.sun.xml.ws.util.Pool<T>
Direct Known Subclasses:
Pool.Marshaller, Pool.TubePool, Pool.Unmarshaller

public abstract class Pool<T> extends Object
General-purpose object pool.

In many parts of the runtime, we need to pool instances of objects that are expensive to create (such as JAXB objects, StAX parsers, Tube instances.)

This class provides a default implementation of such a pool. TODO: improve the implementation

Author:
Kohsuke Kawaguchi
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    JAXB Marshaller pool.
    static final class 
    Tube pool.
    static final class 
    JAXB Marshaller pool.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract T
    Creates a new instance of object.
    final void
    Returns an object back to the pool.
    final T
    Gets a new object from the pool.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Pool

      protected Pool()
      Default constructor.
  • Method Details

    • take

      public final T take()
      Gets a new object from the pool.

      If no object is available in the pool, this method creates a new one.

      Returns:
      always non-null.
    • recycle

      public final void recycle(T t)
      Returns an object back to the pool.
    • create

      protected abstract T create()
      Creates a new instance of object.

      This method is used when someone wants to take an object from an empty pool.

      Also note that multiple threads may call this method concurrently.