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 type
O - the delegate observer type
All Implemented Interfaces:
Observer
Direct Known Subclasses:
ObserverWithDelegateI

public class ObserverWithDelegate<T extends Metrics,O extends Observer> extends Observer<T>
Observer implementation that supports delegation to another observer.
  • Field Details

    • _delegate

      protected O extends Observer _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.
      Specified by:
      attach in interface Observer
      Overrides:
      attach in class Observer<T extends Metrics>
    • 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.
      Specified by:
      detach in interface Observer
      Overrides:
      detach in class Observer<T extends Metrics>
    • failed

      public void failed(String exceptionName)
      Description copied from interface: Observer
      Notification of a failure.
      Specified by:
      failed in interface Observer
      Overrides:
      failed in class Observer<T extends Metrics>
      Parameters:
      exceptionName - The name of the exception.
    • getDelegate

      public O getDelegate()
      Gets the delegate observer.
      Returns:
      the delegate observer, or null if none is set
    • setDelegate

      public void setDelegate(O del)
      Sets the delegate observer.
      Parameters:
      del - the delegate observer to set
    • getObserver

      public <S extends Metrics, ObserverImpl extends ObserverWithDelegate<S, Obs>, Obs extends Observer> Obs getObserver(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 type
      ObserverImpl - the observer implementation type that supports delegation
      Obs - the delegate observer type
      Parameters:
      mapName - the name of the metrics map
      helper - the metrics helper for the sub-metrics type
      mcl - the metrics class
      ocl - the observer class
      delegate - 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