jfun.yan.factory
Class GlobalScope<T>

java.lang.Object
  extended by jfun.yan.factory.CachingPool<T>
      extended by jfun.yan.factory.GlobalScope<T>
All Implemented Interfaces:
java.io.Serializable, Pool<T>

public class GlobalScope<T>
extends CachingPool<T>

Represents a pooling strategy that pools the data in a variable that's global to all threads.
This implementation is thread-safe.

Zephyr Business Solution

Author:
Ben Yu
See Also:
Serialized Form

Constructor Summary
GlobalScope()
           
 
Method Summary
 T getInstance(Factory<T> factory)
          Apply the pooling strategy and return an instance from either the pool or the factory.
 T getPooledInstance(T def)
          Get the instance that's already pooled.
 boolean isPooled()
          Is this pool currently having something in cache?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlobalScope

public GlobalScope()
Method Detail

getInstance

public T getInstance(Factory<T> factory)
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<T>
Overrides:
getInstance in class CachingPool<T>
Parameters:
factory - the factory to create the object instance.
Returns:
the object instance.

getPooledInstance

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

Specified by:
getPooledInstance in interface Pool<T>
Overrides:
getPooledInstance in class CachingPool<T>
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 class: CachingPool
Is this pool currently having something in cache?

Specified by:
isPooled in interface Pool<T>
Overrides:
isPooled in class CachingPool<T>