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.AtomicInteger
counter
A counter for tracking the number of items that have been created.protected java.util.concurrent.atomic.AtomicInteger
disposedCount
-
Constructor Summary
Constructors Constructor Description CountingBasicFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
create()
Creates an instance ofBasicFactory
.void
dispose(T t)
Called when clients are finished with the given item and it should be disposed.abstract T
doCreate(int itemNumber)
The method subclass use to createCountingBasicFactory
s.abstract void
doDispose(T t)
-
-
-
Method Detail
-
create
public T create() throws java.lang.Exception
Description copied from interface:BasicFactory
Creates an instance ofBasicFactory
.- Specified by:
create
in 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:BasicFactory
Called when clients are finished with the given item and it should be disposed.- Specified by:
dispose
in interfaceBasicFactory<T>
- Parameters:
t
- the item to dispose.
-
doCreate
public abstract T doCreate(int itemNumber) throws java.lang.Exception
The method subclass use to createCountingBasicFactory
s.- 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)
-
-