Class DisposableTemplate
- java.lang.Object
-
- com.igormaznitsa.meta.common.templates.DisposableTemplate
-
- All Implemented Interfaces:
Disposable
,java.io.Serializable
public abstract class DisposableTemplate extends java.lang.Object implements Disposable, java.io.Serializable
Template providing disposable functionality. It makes notification of the GCEPS.- Since:
- 1.0
- See Also:
doDispose()
,MetaErrorListeners
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.concurrent.atomic.AtomicLong
DISPOSABLE_OBJECT_COUNTER
private java.util.concurrent.atomic.AtomicBoolean
disposedFlag
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description DisposableTemplate()
The Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
assertNotDisposed()
Auxiliary method to ensure that the object is not disposed.void
dispose()
Dispose object.protected abstract void
doDispose()
The Template method is called once during disposing.static long
getNonDisposedObjectCounter()
Get the current number of created but not disposed object which have DisposableTemplate as super class.boolean
isDisposed()
Check that the object is disposed.
-
-
-
Field Detail
-
DISPOSABLE_OBJECT_COUNTER
private static final java.util.concurrent.atomic.AtomicLong DISPOSABLE_OBJECT_COUNTER
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
disposedFlag
private final java.util.concurrent.atomic.AtomicBoolean disposedFlag
-
-
Constructor Detail
-
DisposableTemplate
@Warning("Must be called in successors") public DisposableTemplate()
The Constructor.- Since:
- 1.0
-
-
Method Detail
-
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 interfaceDisposable
- Returns:
- true if the object is disposed
-
dispose
public final void dispose()
Description copied from interface:Disposable
Dispose object.- Specified by:
dispose
in interfaceDisposable
-
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.
-
-