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 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 CountingBasicFactorys.
      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)