Package org.apache.camel.support
Class TimerListenerManager
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.TimerListenerManager
-
- All Implemented Interfaces:
AutoCloseable,Runnable,org.apache.camel.CamelContextAware,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.StatefulService,org.apache.camel.StaticService,org.apache.camel.SuspendableService
public class TimerListenerManager extends org.apache.camel.support.service.ServiceSupport implements Runnable, org.apache.camel.CamelContextAware, org.apache.camel.StaticService
ATimerListenermanager which triggers theTimerListenerlisteners once every second. Also ensure when adding and remove listeners, that they are correctly removed to avoid leaking memory.- See Also:
TimerListener
-
-
Constructor Summary
Constructors Constructor Description TimerListenerManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTimerListener(org.apache.camel.TimerListener listener)Adds the listener.protected voiddoShutdown()protected voiddoStart()protected voiddoStop()org.apache.camel.CamelContextgetCamelContext()longgetInterval()Gets the interval in millis.protected Set<org.apache.camel.TimerListener>getListeners()A read-only set of the registered listenersvoidremoveTimerListener(org.apache.camel.TimerListener listener)Removes the listener.voidrun()voidsetCamelContext(org.apache.camel.CamelContext camelContext)voidsetInterval(long interval)Sets the interval in millis.-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext)
- Specified by:
setCamelContextin interfaceorg.apache.camel.CamelContextAware
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()
- Specified by:
getCamelContextin interfaceorg.apache.camel.CamelContextAware
-
getInterval
public long getInterval()
Gets the interval in millis. The default interval is 1000 millis.- Returns:
- interval in millis.
-
setInterval
public void setInterval(long interval)
Sets the interval in millis.- Parameters:
interval- interval in millis.
-
addTimerListener
public void addTimerListener(org.apache.camel.TimerListener listener)
Adds the listener. It may be important to implementObject.equals(Object)andObject.hashCode()for the listener to ensure that we can remove the same listener again, when invoking remove.- Parameters:
listener- listener
-
removeTimerListener
public void removeTimerListener(org.apache.camel.TimerListener listener)
Removes the listener. It may be important to implementObject.equals(Object)andObject.hashCode()for the listener to ensure that we can remove the same listener again, when invoking remove.- Parameters:
listener- listener.
-
getListeners
protected Set<org.apache.camel.TimerListener> getListeners()
A read-only set of the registered listeners
-
doStart
protected void doStart() throws Exception- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
protected void doStop() throws Exception- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
-