public final class CompositeFilterCallback extends Object implements FilterCallback, CompositeCallback
addRule(FilterRule.Type, String, String, Callback.Event...)
method and if the rule is satisfied the event is propagated to all
children callbacks added via addCallback(Callback)
. XML facility for configuration
is provided via ManagerConfiguration.readConfig(java.io.Reader)
.
Filter without any rules does not propagate events (default DENY behavior).
Any number of global rules (for Callback.Event.ALL
) and per event rules can be added.
Event rules have higher priority and if the filter passes on event rules, global rules are not consulted.
Rules are checked in the order they were added to the filter.FilterRule
Callback.Event
Constructor and Description |
---|
CompositeFilterCallback()
Constructs composite filter callback.
|
Modifier and Type | Method and Description |
---|---|
void |
addCallback(Callback callback)
Adds another callback as a child to this callback.
|
void |
addRule(FilterRule.Type type,
String condition,
String pattern,
Callback.Event... events)
Adds the rule to the filter.
|
List<Callback> |
callbacks()
Returns the list of all child-callbacks.
|
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 |
removeAllCallbacks()
Removes all callbacks from this callback.
|
void |
removeCallback(Callback callback)
Removes specified callback from this callback.
|
public CompositeFilterCallback()
public List<Callback> callbacks()
CompositeCallback
callbacks
in interface CompositeCallback
public void addCallback(Callback callback)
CompositeCallback
addCallback
in interface CompositeCallback
callback
- added callbackpublic void removeCallback(Callback callback)
CompositeCallback
removeCallback
in interface CompositeCallback
callback
- removed child-callbackpublic void removeAllCallbacks()
CompositeCallback
removeAllCallbacks
in interface CompositeCallback
public void initialize(Manager manager)
Callback
initialize
in interface Callback
public void cleanup()
Callback
public void onStopwatchAdd(Stopwatch stopwatch, Split split, StopwatchSample sample)
Callback
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
.onStopwatchAdd
in interface Callback
stopwatch
- modified Stopwatchsplit
- added split objectsample
- stopwatch sampled after the addpublic void onStopwatchStart(Split split)
Callback
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
.onStopwatchStart
in interface Callback
split
- started Splitpublic void onStopwatchStop(Split split, StopwatchSample sample)
Callback
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
.onStopwatchStop
in interface Callback
split
- stopped Splitsample
- stopwatch sampled after the stoppublic void onCounterDecrease(Counter counter, long dec, CounterSample sample)
Callback
CounterSample
valid for the moment after the operation is provided
because the callback is executed out of synchronized block.onCounterDecrease
in interface Callback
counter
- modified Counterdec
- decrement amountsample
- counter sampled after the operationpublic void onCounterIncrease(Counter counter, long inc, CounterSample sample)
Callback
CounterSample
valid for the moment after the operation is provided
because the callback is executed out of synchronized block.onCounterIncrease
in interface Callback
counter
- modified Counterinc
- increment amountsample
- counter sampled after the operationpublic void onCounterSet(Counter counter, long val, CounterSample sample)
Callback
CounterSample
valid for the moment after the operation is provided
because the callback is executed out of synchronized block.onCounterSet
in interface Callback
counter
- modified Counterval
- new valuesample
- counter sampled after the operationpublic void onSimonCreated(Simon simon)
Callback
onSimonCreated
in interface Callback
simon
- created Simonpublic void onSimonDestroyed(Simon simon)
Callback
onSimonDestroyed
in interface Callback
simon
- destroyed Simonpublic void onManagerClear()
Callback
onManagerClear
in interface Callback
public void onManagerMessage(String message)
Callback
onManagerMessage
in interface Callback
message
- message textpublic void onManagerWarning(String warning, Exception cause)
Callback
onManagerWarning
in interface Callback
warning
- arbitrary warning message - can be null
, unless concrete implementation states otherwisecause
- exception causing this warning - can be null
, unless concrete implementation states otherwisepublic void addRule(FilterRule.Type type, String condition, String pattern, Callback.Event... events)
FilterCallback
addRule
in interface FilterCallback
type
- rule type (must, suffice, must-not)condition
- further conditions of the rulepattern
- Simon patternevents
- event list (empty applies to all, can be omitted)Copyright © 2019. All rights reserved.