Package org.apache.camel.clock
Class ContextClock
java.lang.Object
org.apache.camel.clock.ContextClock
- All Implemented Interfaces:
Clock
,EventClock<ContextEvents>
An event clock that tracks the pass of time for different types of context-related events (see
ContextEvents
)-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(ContextEvents event, Clock clock) Add the event to be trackedasDate
(ContextEvents event, Date defaultValue) Get the time for the event as a Date objectlong
elapsed()
The elapsed time since the creation of the clocklong
elapsed
(ContextEvents event, long defaultValue) Get the elapsed time for the eventget
(ContextEvents event) Get the clock for the eventlong
The point in time the clock was createdMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.camel.clock.Clock
asDate, asDuration, asZonedCreationDateTime
-
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 -
getCreated
public long getCreated()Description copied from interface:Clock
The point in time the clock was created- Specified by:
getCreated
in interfaceClock
- Returns:
- The point in time, in milliseconds, the exchange was created.
- See Also:
-
add
Description copied from interface:EventClock
Add the event to be tracked- Specified by:
add
in interfaceEventClock<ContextEvents>
- Parameters:
event
- the event to trackclock
- the clock associated with the event
-
get
Description copied from interface:EventClock
Get the clock for the event- Specified by:
get
in interfaceEventClock<ContextEvents>
- Parameters:
event
- the event to get the clock for- Returns:
- the clock instance or null if not set
-
elapsed
Get the elapsed time for the event- Parameters:
event
- the event to get the elapsed timedefaultValue
- 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
Get the time for the event as a Date object- Parameters:
event
- the event to get the elapsed timedefaultValue
- 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
-