Class 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
    A 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.

    See Also:
    TimerListener, org.apache.camel.management.ManagedLoadTimer
    • Field Summary

      • Fields inherited from class org.apache.camel.support.service.BaseService

        BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addTimerListener​(org.apache.camel.TimerListener listener)
      Adds the listener.
      protected void doShutdown()  
      protected void doStart()  
      protected void doStop()  
      org.apache.camel.CamelContext getCamelContext()  
      long getInterval()
      Gets the interval in millis.
      void removeTimerListener​(org.apache.camel.TimerListener listener)
      Removes the listener.
      void run()  
      void setCamelContext​(org.apache.camel.CamelContext camelContext)  
      void setInterval​(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 interface org.apache.camel.Service

        build, close, init, start, stop
      • Methods inherited from interface org.apache.camel.ShutdownableService

        shutdown
      • Methods inherited from interface org.apache.camel.StatefulService

        getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
      • Methods inherited from interface org.apache.camel.SuspendableService

        isSuspended, resume, suspend
    • Constructor Detail

      • TimerListenerManager

        public TimerListenerManager()
    • Method Detail

      • setCamelContext

        public void setCamelContext​(org.apache.camel.CamelContext camelContext)
        Specified by:
        setCamelContext in interface org.apache.camel.CamelContextAware
      • getCamelContext

        public org.apache.camel.CamelContext getCamelContext()
        Specified by:
        getCamelContext in interface org.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.
      • run

        public void run()
        Specified by:
        run in interface Runnable
      • addTimerListener

        public void addTimerListener​(org.apache.camel.TimerListener listener)
        Adds the listener.

        It may be important to implement Object.equals(Object) and Object.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 implement Object.equals(Object) and Object.hashCode() for the listener to ensure that we can remove the same listener again, when invoking remove.

        Parameters:
        listener - listener.
      • doStart

        protected void doStart()
                        throws Exception
        Overrides:
        doStart in class org.apache.camel.support.service.BaseService
        Throws:
        Exception
      • doStop

        protected void doStop()
                       throws Exception
        Overrides:
        doStop in class org.apache.camel.support.service.BaseService
        Throws:
        Exception
      • doShutdown

        protected void doShutdown()
                           throws Exception
        Overrides:
        doShutdown in class org.apache.camel.support.service.BaseService
        Throws:
        Exception