ehcache

net.sf.ehcache.pool.impl
Class AbstractPool<T>

java.lang.Object
  extended by net.sf.ehcache.pool.impl.AbstractPool<T>
Type Parameters:
T - the pool store type
All Implemented Interfaces:
Pool<T>
Direct Known Subclasses:
BoundedPool, StrictlyBoundedPool

public abstract class AbstractPool<T>
extends Object
implements Pool<T>

An abstract pool implementation.

This contains all the logic of a pool except for the actual creation of accessor instances.

Author:
Chris Dennis

Constructor Summary
AbstractPool(long maximumPoolSize, PoolEvictor<T> evictor, SizeOfEngine defaultSizeOfEngine)
          Create an AbstractPool instance
 
Method Summary
 PoolAccessor<T> createPoolAccessor(T store, int maxDepth, boolean abortWhenMaxDepthExceeded)
          Return a PoolAccessor whose consumption is tracked by this pool, using a default SizeOf engine.
 PoolEvictor<T> getEvictor()
          Return the pool evictor used by this pool.
 long getMaxSize()
          Return the maximum size of the pool.
 Collection<T> getPoolableStores()
          Return the stores accessing this pool.
 long getSize()
          Return the used size of the pool.
 void registerPoolAccessor(PoolAccessor<? extends T> accessor)
          Register an accessor implementation with this pool.
 void removePoolAccessor(PoolAccessor<?> accessor)
          Remove the supplied accessor from this pool.
 void setMaxSize(long newSize)
          Change the maximum size of the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.ehcache.pool.Pool
createPoolAccessor
 

Constructor Detail

AbstractPool

public AbstractPool(long maximumPoolSize,
                    PoolEvictor<T> evictor,
                    SizeOfEngine defaultSizeOfEngine)
Create an AbstractPool instance

Parameters:
maximumPoolSize - the maximum size of the pool, in bytes.
evictor - the pool evictor, for cross-store eviction.
defaultSizeOfEngine - the default SizeOf engine used by the accessors.
Method Detail

getSize

public long getSize()
Return the used size of the pool.

Specified by:
getSize in interface Pool<T>
Returns:
used size of the pool.

getMaxSize

public long getMaxSize()
Return the maximum size of the pool.

Specified by:
getMaxSize in interface Pool<T>
Returns:
the maximum size of the pool.

setMaxSize

public void setMaxSize(long newSize)
Change the maximum size of the pool.

Specified by:
setMaxSize in interface Pool<T>
Parameters:
newSize - the new pool size.

createPoolAccessor

public PoolAccessor<T> createPoolAccessor(T store,
                                          int maxDepth,
                                          boolean abortWhenMaxDepthExceeded)
Return a PoolAccessor whose consumption is tracked by this pool, using a default SizeOf engine.

Specified by:
createPoolAccessor in interface Pool<T>
Parameters:
store - the store which will use the created accessor.
maxDepth - maximum depth of the object graph to traverse
abortWhenMaxDepthExceeded - true if the object traversal should be aborted when the max depth is exceeded
Returns:
a PoolAccessor whose consumption is tracked by this pool.

registerPoolAccessor

public void registerPoolAccessor(PoolAccessor<? extends T> accessor)
Register an accessor implementation with this pool.

Specified by:
registerPoolAccessor in interface Pool<T>
Parameters:
accessor - accessor to be registered

removePoolAccessor

public void removePoolAccessor(PoolAccessor<?> accessor)
Remove the supplied accessor from this pool.

Specified by:
removePoolAccessor in interface Pool<T>
Parameters:
accessor - accessor to be removed

getPoolableStores

public Collection<T> getPoolableStores()
Return the stores accessing this pool.

Specified by:
getPoolableStores in interface Pool<T>
Returns:
stores using this pool

getEvictor

public PoolEvictor<T> getEvictor()
Return the pool evictor used by this pool.

Specified by:
getEvictor in interface Pool<T>
Returns:
the pool evictor

ehcache

Copyright © 2003-2012 Terracotta, Inc.. All Rights Reserved.