public class TimerListenerManager extends ServiceSupport implements Runnable, CamelContextAware, StaticService
TimerListener
manager which triggers the
TimerListener
listeners once every second.
Also ensure when adding and remove listeners, that they are correctly removed to avoid
leaking memory.
From Camel 2.13 onwards the TimerListenerManager
is only enabled if
ManagementStrategy.isLoadStatisticsEnabled()
is enabled.TimerListener
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Constructor and Description |
---|
TimerListenerManager() |
Modifier and Type | Method and Description |
---|---|
void |
addTimerListener(TimerListener listener)
Adds the listener.
|
protected void |
doShutdown()
Implementations override this method to perform customized shutdown.
|
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
CamelContext |
getCamelContext()
Get the
CamelContext |
long |
getInterval()
Gets the interval in millis.
|
void |
removeTimerListener(TimerListener listener)
Removes the listener.
|
void |
run() |
void |
setCamelContext(CamelContext camelContext)
Injects the
CamelContext |
void |
setInterval(long interval)
Sets the interval in millis.
|
doResume, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
public TimerListenerManager()
public void setCamelContext(CamelContext camelContext)
CamelContextAware
CamelContext
setCamelContext
in interface CamelContextAware
camelContext
- the Camel contextpublic CamelContext getCamelContext()
CamelContextAware
CamelContext
getCamelContext
in interface CamelContextAware
public long getInterval()
public void setInterval(long interval)
interval
- interval in millis.public void addTimerListener(TimerListener listener)
Object.equals(Object)
and Object.hashCode()
for the listener
to ensure that we can remove the same listener again, when invoking remove.listener
- listenerpublic void removeTimerListener(TimerListener listener)
Object.equals(Object)
and Object.hashCode()
for the listener
to ensure that we can remove the same listener again, when invoking remove.listener
- listener.protected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.doStop()
method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext
is shutting down.doStop
in class ServiceSupport
Exception
ServiceSupport.doStart()
protected void doShutdown() throws Exception
ServiceSupport
doShutdown
in class ServiceSupport
Exception
Apache Camel