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.AtomicLongDISPOSABLE_OBJECT_COUNTERprivate java.util.concurrent.atomic.AtomicBooleandisposedFlagprivate static longserialVersionUID
-
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 voidassertNotDisposed()Auxiliary method to ensure that the object is not disposed.voiddispose()Dispose object.protected abstract voiddoDispose()The Template method is called once during disposing.static longgetNonDisposedObjectCounter()Get the current number of created but not disposed object which have DisposableTemplate as super class.booleanisDisposed()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:DisposableCheck that the object is disposed.- Specified by:
isDisposedin interfaceDisposable- Returns:
- true if the object is disposed
-
dispose
public final void dispose()
Description copied from interface:DisposableDispose object.- Specified by:
disposein 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.
-
-