org.javasimon.callback
Class CompositeCallbackImpl

java.lang.Object
  extended by org.javasimon.callback.CompositeCallbackImpl
All Implemented Interfaces:
Callback, CompositeCallback

public final class CompositeCallbackImpl
extends Object
implements CompositeCallback

Composite callbacks holds child-callbacks and delegates any operations to all of them. It implements callbacks(), addCallback(Callback) and removeCallback(Callback).

Author:
Richard "Virgo" Richter

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.javasimon.callback.Callback
Callback.Event
 
Field Summary
private  List<Callback> callbacks
           
private  boolean initialized
           
 
Constructor Summary
CompositeCallbackImpl()
           
 
Method Summary
 void addCallback(Callback callback)
          Adds another callback as a child to this callback.
 List<Callback> callbacks()
          Returns the list of all child-callbacks.
 void cleanup()
          Calls deactivate on all children.
 void initialize()
          Calls initialize on all children.
 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 onSimonReset(Simon simon)
          Simon reset event.
 void onStopwatchAdd(Stopwatch stopwatch, long ns, StopwatchSample sample)
          Stopwatch add time event.
 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 specified callback from this callback, properly cleans up all the removed callbacks.
 void removeCallback(Callback callback)
          Removes specified callback from this callback, properly cleans up the removed callback.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

callbacks

private List<Callback> callbacks

initialized

private boolean initialized
Constructor Detail

CompositeCallbackImpl

public CompositeCallbackImpl()
Method Detail

callbacks

public List<Callback> callbacks()
Returns the list of all child-callbacks.

Specified by:
callbacks in interface CompositeCallback
Returns:
children list

addCallback

public void addCallback(Callback callback)
Adds another callback as a child to this callback.

Specified by:
addCallback in interface CompositeCallback
Parameters:
callback - added callback

removeCallback

public void removeCallback(Callback callback)
Removes specified callback from this callback, properly cleans up the removed callback.

Specified by:
removeCallback in interface CompositeCallback
Parameters:
callback - removed child-callback

removeAllCallbacks

public void removeAllCallbacks()
Removes specified callback from this callback, properly cleans up all the removed callbacks.

Specified by:
removeAllCallbacks in interface CompositeCallback

initialize

public void initialize()
Calls initialize on all children.

Specified by:
initialize in interface Callback

cleanup

public void cleanup()
Calls deactivate on all children.

Specified by:
cleanup in interface Callback

onSimonReset

public void onSimonReset(Simon simon)
Description copied from interface: Callback
Simon reset event.

Specified by:
onSimonReset in interface Callback
Parameters:
simon - reset Simon

onStopwatchAdd

public void onStopwatchAdd(Stopwatch stopwatch,
                           long ns,
                           StopwatchSample sample)
Description copied from interface: Callback
Stopwatch add time event. StopwatchSample valid for the moment after the add is provided because the callback is executed out of synchronized block.

Specified by:
onStopwatchAdd in interface Callback
Parameters:
stopwatch - modified Stopwatch
ns - added split time in ns
sample - stopwatch sampled after the add

onStopwatchAdd

public void onStopwatchAdd(Stopwatch stopwatch,
                           Split split,
                           StopwatchSample sample)
Description copied from interface: Callback
Stopwatch add split event. StopwatchSample valid for the moment after the add is provided because the callback is executed out of synchronized block.

Specified by:
onStopwatchAdd in interface Callback
Parameters:
stopwatch - modified Stopwatch
split - added split object
sample - stopwatch sampled after the add

onStopwatchStart

public void onStopwatchStart(Split split)
Description copied from interface: Callback
Stopwatch start event. Duration of all callbacks is included into the split time! StopwatchSample valid for the moment after the start is provided because the callback is executed out of synchronized block.

Specified by:
onStopwatchStart in interface Callback
Parameters:
split - started Split

onStopwatchStop

public void onStopwatchStop(Split split,
                            StopwatchSample sample)
Description copied from interface: Callback
Stopwatch stop event. This action is executed after the split time is calculated and does not affect the measuring. StopwatchSample valid for the moment after the stop is provided because the callback is executed out of synchronized block.

Specified by:
onStopwatchStop in interface Callback
Parameters:
split - stopped Split
sample - stopwatch sampled after the stop

onCounterDecrease

public void onCounterDecrease(Counter counter,
                              long dec,
                              CounterSample sample)
Description copied from interface: Callback
Counter decrease event. CounterSample valid for the moment after the operation is provided because the callback is executed out of synchronized block.

Specified by:
onCounterDecrease in interface Callback
Parameters:
counter - modified Counter
dec - decrement amount
sample - counter sampled after the operation

onCounterIncrease

public void onCounterIncrease(Counter counter,
                              long inc,
                              CounterSample sample)
Description copied from interface: Callback
Counter increase event. CounterSample valid for the moment after the operation is provided because the callback is executed out of synchronized block.

Specified by:
onCounterIncrease in interface Callback
Parameters:
counter - modified Counter
inc - increment amount
sample - counter sampled after the operation

onCounterSet

public void onCounterSet(Counter counter,
                         long val,
                         CounterSample sample)
Description copied from interface: Callback
Counter set event. CounterSample valid for the moment after the operation is provided because the callback is executed out of synchronized block.

Specified by:
onCounterSet in interface Callback
Parameters:
counter - modified Counter
val - new value
sample - counter sampled after the operation

onSimonCreated

public void onSimonCreated(Simon simon)
Description copied from interface: Callback
Simon created event is called when Simon is successfully created by the Manager.

Specified by:
onSimonCreated in interface Callback
Parameters:
simon - created Simon

onSimonDestroyed

public void onSimonDestroyed(Simon simon)
Description copied from interface: Callback
Simon destroyed event is called when Simon is successfully destroyed by the Manager.

Specified by:
onSimonDestroyed in interface Callback
Parameters:
simon - destroyed Simon

onManagerClear

public void onManagerClear()
Description copied from interface: Callback
Event called when the manager is cleared.

Specified by:
onManagerClear in interface Callback

onManagerMessage

public void onManagerMessage(String message)
Description copied from interface: Callback
Message event is used to propagate arbitrary messages from the manager, or it can be used by the other Callback methods internally.

Specified by:
onManagerMessage in interface Callback
Parameters:
message - message text

onManagerWarning

public void onManagerWarning(String warning,
                             Exception cause)
Description copied from interface: Callback
Warning event containing warning and/or cause.

Specified by:
onManagerWarning in interface Callback
Parameters:
warning - arbitrary warning message - can be null, unless concrete implementation states otherwise
cause - exception causing this warning - can be null, unless concrete implementation states otherwise


Copyright © 2013. All Rights Reserved.