Package generic.cache

# Class CountingBasicFactory<T>

java.lang.Object
generic.cache.CountingBasicFactory<T>

All Implemented Interfaces:
  `BasicFactory<T>`

public abstract class CountingBasicFactory<T> extends Object implements BasicFactory<T>

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected AtomicInteger`
  `counter`
  A counter for tracking the number of items that have been created.
  `protected AtomicInteger`
  `disposedCount`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CountingBasicFactory()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `T`
  `create()`
  Creates an instance of `BasicFactory`.
  `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 create `CountingBasicFactory`s.
  `abstract void`
  `doDispose(T t)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### counter

    protected AtomicInteger counter
    A counter for tracking the number of items that have been created.

  - ### disposedCount

    protected AtomicInteger disposedCount

- ## Constructor Details

  - ### CountingBasicFactory

    public CountingBasicFactory()

- ## Method Details

  - ### create

    public T create() throws Exception
    Description copied from interface: `BasicFactory`
    Creates an instance of `BasicFactory`.
    Specified by:
      `create` in interface `BasicFactory<T>`
    Returns:
      the new instance of T
    Throws:
      `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 interface `BasicFactory<T>`
    Parameters:
      `t` - the item to dispose.

  - ### doCreate

    public abstract T doCreate(int itemNumber) throws Exception
    The method subclass use to create `CountingBasicFactory`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:
      `Exception` - any Exception encountered during creation

  - ### doDispose

    public abstract void doDispose(T t)