com.sun.xml.ws.db.toplink
Class ObjectPool<T>

java.lang.Object
  extended by com.sun.xml.ws.db.toplink.ObjectPool<T>
Type Parameters:
T - the type of the object to pool

public abstract class ObjectPool<T>
extends Object

Object pool allocator that leverages a ConcurrentLinkedQueue for synchronization.


Constructor Summary
ObjectPool()
           
 
Method Summary
 T allocate()
          Allocate an object from the pool or create a new one if we cannot get one from the queue.
protected abstract  T newInstance()
          Subclasses must override the object creation method.
 void replace(T value)
          Return an object to the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectPool

public ObjectPool()
Method Detail

allocate

public final T allocate()
Allocate an object from the pool or create a new one if we cannot get one from the queue.

Returns:
the queued or newly-created object

replace

public final void replace(T value)
Return an object to the pool.

Parameters:
value - the object being returned

newInstance

protected abstract T newInstance()
Subclasses must override the object creation method.

Returns:
a new instance of the object.


Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.