Class ContextClock

java.lang.Object
org.apache.camel.clock.ContextClock
All Implemented Interfaces:
Clock, EventClock<ContextEvents>

public final class ContextClock extends Object implements EventClock<ContextEvents>
An event clock that tracks the pass of time for different types of context-related events (see ContextEvents)
  • Constructor Details

    • ContextClock

      public ContextClock()
  • Method Details

    • elapsed

      public long elapsed()
      Description copied from interface: Clock
      The elapsed time since the creation of the clock
      Specified by:
      elapsed in interface Clock
      Returns:
      The elapsed time, in milliseconds, since the creation of the exchange
    • getCreated

      public long getCreated()
      Description copied from interface: Clock
      The point in time the clock was created
      Specified by:
      getCreated in interface Clock
      Returns:
      The point in time, in milliseconds, the exchange was created.
      See Also:
    • add

      public void add(ContextEvents event, Clock clock)
      Description copied from interface: EventClock
      Add the event to be tracked
      Specified by:
      add in interface EventClock<ContextEvents>
      Parameters:
      event - the event to track
      clock - the clock associated with the event
    • get

      public Clock get(ContextEvents event)
      Description copied from interface: EventClock
      Get the clock for the event
      Specified by:
      get in interface EventClock<ContextEvents>
      Parameters:
      event - the event to get the clock for
      Returns:
      the clock instance or null if not set
    • elapsed

      public long elapsed(ContextEvents event, long defaultValue)
      Get the elapsed time for the event
      Parameters:
      event - the event to get the elapsed time
      defaultValue - the default value to provide if the event is not being tracked
      Returns:
      The elapsed time or the default value if the event is not being tracked
    • asDate

      public Date asDate(ContextEvents event, Date defaultValue)
      Get the time for the event as a Date object
      Parameters:
      event - the event to get the elapsed time
      defaultValue - the default value to provide if the event is not being tracked
      Returns:
      The Date object representing the creation date or the default value if the event is not being tracked