Package generic.cache

Class 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  
    • Field Detail

      • counter

        protected java.util.concurrent.atomic.AtomicInteger counter
        A counter for tracking the number of items that have been created.
      • disposedCount

        protected java.util.concurrent.atomic.AtomicInteger disposedCount
    • Constructor Detail

      • CountingBasicFactory

        public CountingBasicFactory()
    • Method Detail

      • create

        public T create()
                 throws java.lang.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:
        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 interface BasicFactory<T>
        Parameters:
        t - the item to dispose.
      • doCreate

        public abstract T doCreate​(int itemNumber)
                            throws java.lang.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:
        java.lang.Exception - any Exception encountered during creation
      • doDispose

        public abstract void doDispose​(T t)