Package generic.cache
Class CountingBasicFactory<T>
java.lang.Object
generic.cache.CountingBasicFactory<T>
- All Implemented Interfaces:
BasicFactory<T>
-
Field Summary
Modifier and TypeFieldDescriptionprotected AtomicInteger
A counter for tracking the number of items that have been created.protected AtomicInteger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreate()
Creates an instance ofBasicFactory
.void
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
-
Field Details
-
counter
A counter for tracking the number of items that have been created. -
disposedCount
-
-
Constructor Details
-
CountingBasicFactory
public CountingBasicFactory()
-
-
Method Details
-
create
Description copied from interface:BasicFactory
Creates an instance ofBasicFactory
.- Specified by:
create
in interfaceBasicFactory<T>
- Returns:
- the new instance of T
- Throws:
Exception
- any Exception encountered during creation
-
dispose
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
The method subclass use to createCountingBasicFactory
s.- Parameters:
itemNumber
- the number of the item being created-- one-based; the first item is item1
.- Returns:
- a new instance of
CountingBasicFactory
. - Throws:
Exception
- any Exception encountered during creation
-
doDispose
-