Skip navigation links

Oracle Fusion Middleware Crypto Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10668-04


oracle.security.crypto.util
Class ObjectPool

java.lang.Object
  extended by oracle.security.crypto.util.ObjectPool


public class ObjectPool
extends java.lang.Object

A generic object pool.

The default starting size is 64 objects, and the growth factor is 2.

The pool will be initially filled upon the first invocation of the getObject method, and will automatically grow in the event that getObject finds the pool empty. To initially fill the pool in advance, use the initialize method. Subsequent calls to initialize have no effect.

Objects are obtained from the pool by invoking the getObject method and casting the result to the underlying type. When the object is no longer needed, it may be returned to the pool by invoking the releaseObject method.

To pool a type of object whose constructor takes arguments or whose instances require additional initialization after construction, extend ObjectPool and override the newObject method.


Constructor Summary
ObjectPool(java.lang.Class type)
          Create a new ObjectPool, with the default starting size, to pool objects of the specified type.
ObjectPool(int startSize, java.lang.Class type)
          Create a new ObjectPool, with the specified starting size, to pool objects of the specified type.

 

Method Summary
 int available()
          Returns the number of pooled objects that are not currently in use.
 java.lang.Object getObject()
          Returns an object from the pool.
 java.lang.Class getObjectType()
          Returns the Class for the pooled objects.
 void initialize()
          Initially fills the pool with the starting number of objects.
protected  java.lang.Object newObject()
          Subclasses of ObjectPool should override this method in order to pool objects whose constructors require arguments or that require post-construction initialization.
 void releaseObject(java.lang.Object obj)
          Returns the given object to the pool.
 int size()
          Returns the total size of the pool, including objects that are currently in use.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

ObjectPool

public ObjectPool(java.lang.Class type)
Create a new ObjectPool, with the default starting size, to pool objects of the specified type.

The pool is not filled upon creation. The first call to the getObject method will result in the pool being filled. Alternatively, call the initialize method to fill the pool with constructed objects.

Parameters:
type - The Class of the objects to be pooled.
See Also:
getObject(), initialize()

ObjectPool

public ObjectPool(int startSize,
                  java.lang.Class type)
Create a new ObjectPool, with the specified starting size, to pool objects of the specified type.

The pool is not filled upon creation. The first call to the getObject method will result in the pool being filled. Alternatively, call the initialize method to fill the pool with constructed objects.

Parameters:
startSize - The initial number of objects to fill the pool.
type - The Class of the objects to be pooled.
See Also:
getObject(), initialize()

Method Detail

initialize

public void initialize()
Initially fills the pool with the starting number of objects. Subsequent calls to this method have no effect. Invoking this method after getObject has been called also has no effect.
See Also:
getObject()

getObject

public java.lang.Object getObject()
Returns an object from the pool. If the pool is empty (or was not initially filled), new objects are created to fill the pool. Once this method has been invoked, calls to the initialize method have no effect.
Returns:
An object of the pooled type.
See Also:
initialize()

releaseObject

public void releaseObject(java.lang.Object obj)
Returns the given object to the pool. Attempting to return to the pool an object that was not obtained via the getObject method has no effect.
Parameters:
obj - The object to be returned to the pool.

size

public int size()
Returns the total size of the pool, including objects that are currently in use.
See Also:
available()

available

public int available()
Returns the number of pooled objects that are not currently in use.
See Also:
size

getObjectType

public java.lang.Class getObjectType()
Returns the Class for the pooled objects.

newObject

protected java.lang.Object newObject()
Subclasses of ObjectPool should override this method in order to pool objects whose constructors require arguments or that require post-construction initialization.

Skip navigation links

Oracle Fusion Middleware Crypto Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10668-04


Copyright © 2005, 2011 , Oracle. All rights reserved.