public interface Callback
Manager
using its CompositeCallback
that can be obtained by calling Manager.callback()
. After adding the callback
into the main composite callback (or anywhere lower into the callback tree) by calling
CompositeCallback.addCallback(Callback)
all events are propagated to all Callbacks (unless filtered
using FilterCallback
). Methods called on various events are named onEventXY
with type of the source
clearly mentioned in the name (Manager, Simon, Stopwatch, Counter).
Callbacks can be configured via Manager configuration facility. (Configuration part is still rather WIP.)
Callback can have a lifecycle supported with methods initialize(Manager)
and cleanup()
.
Callback is initialized when it is attached to the manager (anywhere in the callback tree) and
deinitialized when the callback is removed from the callback tree.Modifier and Type | Interface and Description |
---|---|
static class |
Callback.Event
Enumeration of all supported callback actions.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Lifecycle method called when the callback is removed from the manager.
|
void |
initialize(Manager manager)
Lifecycle method called when the callback is added to a manager.
|
void |
onCounterDecrease(Counter counter,
long dec,
CounterSample sample)
Counter decrease event.
|
void |
onCounterIncrease(Counter counter,
long inc,
CounterSample sample)
Counter increase event.
|
void |
onCounterSet(Counter counter,
long val,
CounterSample sample)
Counter set event.
|
void |
onManagerClear()
Event called when the manager is cleared.
|
void |
onManagerMessage(String message)
Message event is used to propagate arbitrary messages from the manager, or it can
be used by the other Callback methods internally.
|
void |
onManagerWarning(String warning,
Exception cause)
Warning event containing warning and/or cause.
|
void |
onSimonCreated(Simon simon)
Simon created event is called when Simon is successfully created by the Manager.
|
void |
onSimonDestroyed(Simon simon)
Simon destroyed event is called when Simon is successfully destroyed by the Manager.
|
void |
onStopwatchAdd(Stopwatch stopwatch,
Split split,
StopwatchSample sample)
Stopwatch add split event.
|
void |
onStopwatchStart(Split split)
Stopwatch start event.
|
void |
onStopwatchStop(Split split,
StopwatchSample sample)
Stopwatch stop event.
|
void initialize(Manager manager)
void cleanup()
void onStopwatchStart(Split split)
StopwatchSample
valid for the moment after the start is provided because the callback
is executed out of synchronized block.
It is guaranteed that Split.getStopwatch()
will not return null
.split
- started Splitvoid onStopwatchStop(Split split, StopwatchSample sample)
StopwatchSample
valid for the moment after the stop is provided
because the callback is executed out of synchronized block.
It is guaranteed that Split.getStopwatch()
will not return null
.split
- stopped Splitsample
- stopwatch sampled after the stopvoid onStopwatchAdd(Stopwatch stopwatch, Split split, StopwatchSample sample)
StopwatchSample
valid for the moment after the add is provided
because the callback is executed out of synchronized block.
It is guaranteed that Split.getStopwatch()
will not return null
.stopwatch
- modified Stopwatchsplit
- added split objectsample
- stopwatch sampled after the addvoid onCounterDecrease(Counter counter, long dec, CounterSample sample)
CounterSample
valid for the moment after the operation is provided
because the callback is executed out of synchronized block.counter
- modified Counterdec
- decrement amountsample
- counter sampled after the operationvoid onCounterIncrease(Counter counter, long inc, CounterSample sample)
CounterSample
valid for the moment after the operation is provided
because the callback is executed out of synchronized block.counter
- modified Counterinc
- increment amountsample
- counter sampled after the operationvoid onCounterSet(Counter counter, long val, CounterSample sample)
CounterSample
valid for the moment after the operation is provided
because the callback is executed out of synchronized block.counter
- modified Counterval
- new valuesample
- counter sampled after the operationvoid onSimonCreated(Simon simon)
simon
- created Simonvoid onSimonDestroyed(Simon simon)
simon
- destroyed Simonvoid onManagerClear()
void onManagerMessage(String message)
message
- message textvoid onManagerWarning(String warning, Exception cause)
warning
- arbitrary warning message - can be null
, unless concrete implementation states otherwisecause
- exception causing this warning - can be null
, unless concrete implementation states otherwiseCopyright © 2019. All rights reserved.