org.codehaus.xfire.util.factory
Class SimplePool

java.lang.Object
  extended by org.codehaus.xfire.util.factory.SimplePool
All Implemented Interfaces:
Serializable, Pool

public abstract class SimplePool
extends Object
implements Pool

A simple implementation of Pool that uses null to indicate non-existent pool entry.

This implementation synchronizes on getMutex() for thread safety.

Author:
Ben Yu Feb 2, 2006 3:14:45 PM
See Also:
Serialized Form

Constructor Summary
SimplePool()
           
 
Method Summary
abstract  Object get()
          Get the pooled instance.
 Object getInstance(Factory factory)
          Apply the pooling strategy and return an instance from either the pool or the factory.
protected abstract  Object getMutex()
          Get the object that can be used to synchronize.
 Object getPooledInstance(Object def)
          Get the instance that's already pooled.
protected static Object ifnull(Object obj, Object def)
           
 boolean isPooled()
          Is this pool currently having something in cache?
abstract  void set(Object val)
          set an value to the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimplePool

public SimplePool()
Method Detail

getInstance

public Object getInstance(Factory factory)
                   throws Throwable
Description copied from interface: Pool
Apply the pooling strategy and return an instance from either the pool or the factory.

Specified by:
getInstance in interface Pool
Parameters:
factory - the factory to create the object instance.
Returns:
the object instance.
Throws:
Throwable

getPooledInstance

public Object getPooledInstance(Object def)
Description copied from interface: Pool
Get the instance that's already pooled.

Specified by:
getPooledInstance in interface Pool
Parameters:
def - the default value to return if there's no pooled instance.
Returns:
the pooled instance or the default object.

isPooled

public boolean isPooled()
Description copied from interface: Pool
Is this pool currently having something in cache?

Specified by:
isPooled in interface Pool

ifnull

protected static Object ifnull(Object obj,
                               Object def)

get

public abstract Object get()
Get the pooled instance. null if not found.

Returns:
the pooled instance.

set

public abstract void set(Object val)
set an value to the pool.

Parameters:
val - the value to be pooled.

getMutex

protected abstract Object getMutex()
Get the object that can be used to synchronize.



Copyright © 2004-2013. All Rights Reserved.