Module com.zeroc.ice
Package com.zeroc.IceMX
Class ObserverWithDelegate<T extends Metrics,O extends Observer>
java.lang.Object
com.zeroc.IceMX.Observer<T>
com.zeroc.IceMX.ObserverWithDelegate<T,O>
- Type Parameters:
T
- the metrics typeO
- the delegate observer type
- All Implemented Interfaces:
Observer
- Direct Known Subclasses:
ObserverWithDelegateI
Observer implementation that supports delegation to another observer.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.zeroc.IceMX.Observer
Observer.MetricsUpdate<T>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
attach()
This method is called when the instrumented object is created or when the observer is attached to an existing object.long
delay()
Gets the current elapsed time without stopping the stopwatch.void
detach()
This method is called when the instrumented object is destroyed and as a result the observer detached from the object.void
Notification of a failure.Gets the delegate observer.<S extends Metrics,
ObserverImpl extends ObserverWithDelegate<S, Obs>, Obs extends Observer>
ObsgetObserver
(String mapName, MetricsHelper<S> helper, Class<S> mcl, Class<ObserverImpl> ocl, Obs delegate) Gets a sub-observer with a delegate for the specified metrics type.boolean
Checks whether the stopwatch is currently running.void
setDelegate
(O del) Sets the delegate observer.void
start()
Starts the stopwatch.long
stop()
Stops the stopwatch and returns the elapsed time.Methods inherited from class com.zeroc.IceMX.Observer
forEach, getEntry, getObserver, init
-
Field Details
-
_delegate
The delegate observer.
-
-
Constructor Details
-
ObserverWithDelegate
public ObserverWithDelegate()
-
-
Method Details
-
attach
public void attach()Description copied from interface:Observer
This method is called when the instrumented object is created or when the observer is attached to an existing object. -
detach
public void detach()Description copied from interface:Observer
This method is called when the instrumented object is destroyed and as a result the observer detached from the object. -
failed
Description copied from interface:Observer
Notification of a failure. -
getDelegate
Gets the delegate observer.- Returns:
- the delegate observer, or null if none is set
-
setDelegate
Sets the delegate observer.- Parameters:
del
- the delegate observer to set
-
getObserver
public <S extends Metrics,ObserverImpl extends ObserverWithDelegate<S, Obs getObserverObs>, Obs extends Observer> (String mapName, MetricsHelper<S> helper, Class<S> mcl, Class<ObserverImpl> ocl, Obs delegate) Gets a sub-observer with a delegate for the specified metrics type.- Type Parameters:
S
- the sub-metrics typeObserverImpl
- the observer implementation type that supports delegationObs
- the delegate observer type- Parameters:
mapName
- the name of the metrics maphelper
- the metrics helper for the sub-metrics typemcl
- the metrics classocl
- the observer classdelegate
- the delegate observer- Returns:
- the sub-observer with delegate set, or the delegate if no matching entries are found
-
start
public void start()Starts the stopwatch. -
stop
public long stop()Stops the stopwatch and returns the elapsed time.- Returns:
- the elapsed time in microseconds
-
isStarted
public boolean isStarted()Checks whether the stopwatch is currently running.- Returns:
- true if the stopwatch is started, false otherwise
-
delay
public long delay()Gets the current elapsed time without stopping the stopwatch.- Returns:
- the elapsed time in microseconds since start was called
-