public abstract class InstrumentedListenerAdapter extends InstrumentedListener
BaseTable.ListenerImpl
InstrumentedListener.ErrorNotification, InstrumentedListener.Notification
Modifier and Type | Field and Description |
---|---|
protected DynamicTable |
source |
Constructor and Description |
---|
InstrumentedListenerAdapter(DynamicTable source)
Create an instrumented listener for source.
|
InstrumentedListenerAdapter(String description,
DynamicTable source)
Create an instrumented listener for source.
|
InstrumentedListenerAdapter(String description,
DynamicTable source,
boolean retain) |
Modifier and Type | Method and Description |
---|---|
protected void |
destroy()
Attempt to release (destructively when necessary) resources held by this object.
|
void |
dropReference()
Drop a previously-retained reference to this referent.
|
WeakReference<? extends LivenessReferent> |
getWeakReference()
Get a
WeakReference to this referent. |
void |
initializeTransientFieldsForLiveness()
Package-private for
Serializable sub-classes to use in readObject only. |
void |
onFailureInternal(Throwable originalException,
UpdatePerformanceTracker.Entry sourceEntry)
Called when the source table produces an error
|
protected void |
onReferenceCountAtZero()
Callback method that will be invoked when the reference count returns to zero.
|
abstract void |
onUpdate(Index added,
Index removed,
Index modified)
Process notification of table changes.
|
boolean |
tryManage(LivenessReferent referent)
Attempt to add the specified referent to this manager.
|
boolean |
tryRetainReference()
If this referent is "live", behave as
LivenessReferent.retainReference() and return true. |
append, getEntry, getErrorNotification, getNotification, onFailure, satisfied, setInitialImage, setVerboseLogging, toString
manageWithCurrentScope, unmanage, unmanage
decrementReferenceCount, incrementReferenceCount, resetReferenceCount, tryDecrementReferenceCount, tryIncrementReferenceCount
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dropReference, getReferentDescription, getWeakReference, retainReference, tryRetainReference
manage, tryManage
@ReferentialIntegrity protected final DynamicTable source
public InstrumentedListenerAdapter(DynamicTable source)
source
- The source table this listener will subscribe to - needed for preserving referential integrity.public InstrumentedListenerAdapter(@Nullable String description, DynamicTable source)
description
- A description for the UpdatePerformanceTracker to append to its entry description.source
- The source table this listener will subscribe to - needed for preserving referential integrity.public InstrumentedListenerAdapter(@Nullable String description, DynamicTable source, boolean retain)
description
- A description for the UpdatePerformanceTracker to append to its entry description.source
- The source table this listener will subscribe to - needed for preserving referential integrity.retain
- Whether a hard reference to this listener should be maintained to prevent it from being collected.public abstract void onUpdate(Index added, Index removed, Index modified)
Listener
onUpdate
in interface Listener
onUpdate
in class InstrumentedListener
added
- rows addedremoved
- rows removedmodified
- rows modifiedpublic void onFailureInternal(Throwable originalException, UpdatePerformanceTracker.Entry sourceEntry)
onFailureInternal
in class InstrumentedListener
originalException
- the original throwable that caused this errorsourceEntry
- the performance tracker entry that was active when the error occurredprotected void destroy()
Attempt to release (destructively when necessary) resources held by this object. This may render the object unusable for subsequent operations. Implementations should be sure to call super.destroy().
This is intended to only ever be used as a side effect of decreasing the reference count to 0.
@VisibleForTesting public final void initializeTransientFieldsForLiveness()
Serializable
sub-classes to use in readObject
only.
Public to allow unit tests in another package to work around mock issues where the constructor is never invoked.public final boolean tryRetainReference()
LivenessReferent
LivenessReferent.retainReference()
and return true.
Otherwise, returns false rather than throwing an exception.tryRetainReference
in interface LivenessReferent
public final void dropReference()
LivenessReferent
dropReference
in interface LivenessReferent
public WeakReference<? extends LivenessReferent> getWeakReference()
LivenessReferent
WeakReference
to this referent. This may be cached, or newly created.getWeakReference
in interface LivenessReferent
public final boolean tryManage(@NotNull LivenessReferent referent)
LivenessManager
tryManage
in interface LivenessManager
referent
- The referent to addprotected final void onReferenceCountAtZero()
ReferenceCounted
onReferenceCountAtZero
in class ReferenceCounted