Class DisposableTemplate

java.lang.Object
com.igormaznitsa.meta.common.templates.DisposableTemplate
All Implemented Interfaces:
Disposable, Serializable

public abstract class DisposableTemplate extends Object implements Disposable, Serializable
Template providing disposable functionality. It makes notification of the GCEPS.
Since:
1.0
See Also:
  • Field Details

    • DISPOSABLE_OBJECT_COUNTER

      private static final AtomicLong DISPOSABLE_OBJECT_COUNTER
    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • disposedFlag

      private final AtomicBoolean disposedFlag
  • Constructor Details

    • DisposableTemplate

      @Warning("Must be called in successors") public DisposableTemplate()
      The Constructor.
      Since:
      1.0
  • Method Details

    • assertNotDisposed

      protected void assertNotDisposed()
      Auxiliary method to ensure that the object is not disposed.
      Throws:
      AlreadyDisposedError - if the object has been already disposed, with notification of the global error listeners
      Since:
      1.0
    • isDisposed

      public boolean isDisposed()
      Description copied from interface: Disposable
      Check that the object is disposed.
      Specified by:
      isDisposed in interface Disposable
      Returns:
      true if the object is disposed
    • dispose

      public final void dispose()
      Description copied from interface: Disposable
      Dispose object.
      Specified by:
      dispose in interface Disposable
    • getNonDisposedObjectCounter

      public static long getNonDisposedObjectCounter()
      Get the current number of created but not disposed object which have DisposableTemplate as super class.
      Returns:
      long value shows number of non-disposed objects.
      Since:
      1.0
    • doDispose

      protected abstract void doDispose()
      The Template method is called once during disposing.