Package generic.cache
Class CountingBasicFactory<T>
- java.lang.Object
-
- generic.cache.CountingBasicFactory<T>
-
- All Implemented Interfaces:
BasicFactory<T>
public abstract class CountingBasicFactory<T> extends java.lang.Object implements BasicFactory<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.atomic.AtomicIntegercounterA counter for tracking the number of items that have been created.protected java.util.concurrent.atomic.AtomicIntegerdisposedCount
-
Constructor Summary
Constructors Constructor Description CountingBasicFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Tcreate()Creates an instance ofBasicFactory.voiddispose(T t)Called when clients are finished with the given item and it should be disposed.abstract TdoCreate(int itemNumber)The method subclass use to createCountingBasicFactorys.abstract voiddoDispose(T t)
-
-
-
Method Detail
-
create
public T create() throws java.lang.Exception
Description copied from interface:BasicFactoryCreates an instance ofBasicFactory.- Specified by:
createin interfaceBasicFactory<T>- Returns:
- the new instance of T
- Throws:
java.lang.Exception- any Exception encountered during creation
-
dispose
public void dispose(T t)
Description copied from interface:BasicFactoryCalled when clients are finished with the given item and it should be disposed.- Specified by:
disposein interfaceBasicFactory<T>- Parameters:
t- the item to dispose.
-
doCreate
public abstract T doCreate(int itemNumber) throws java.lang.Exception
The method subclass use to createCountingBasicFactorys.- Parameters:
itemNumber- the number of the item being created-- one-based; the first item is item 1.- Returns:
- a new instance of
CountingBasicFactory. - Throws:
java.lang.Exception- any Exception encountered during creation
-
doDispose
public abstract void doDispose(T t)
-
-