Class ETimer

  • All Implemented Interfaces:
    EObject, EReplier

    @Deprecated
    public final class ETimer
    extends java.lang.Object
    implements EReplier
    Deprecated.
    Please move to net.sf.eBus.client.EScheduledTimer for scheduled task timing.
    This class provides an eBus request/reply interface on top of the Java Timer class. This eBus interface provides applications a uniform event interface: objects receive events as messages from the eBus API. If the Java timer interface is used directly, then timer events must be manually integrated into the event-processing logic.

    This interface is not to be preferred if timer tasks are used autonomously rather than as events delivered to an eBus client. In that case, the Java TimerTask should be used directly.

    ETimer service must be started by an application by calling one of the startETimer methods before application objects can successfully subscribe to the timer server. ETimer service is local to the JVM only. Requestors cannot access a remote eBus timer service.

    See net.sf.eBusx.util package documentation for sample code.

    Author:
    Charles W. Rapp
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_TIMER_NAME
      Deprecated.
      The default timer name is "ETimer".
      static EMessageKey TIMER_KEY
      Deprecated.
      The advertised request message key is TimerRequest:/eBusTimer.
      static java.lang.String TIMER_SUBJECT
      Deprecated.
      The advertised request message subject is "/eBusTimer".
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void cancelRequest​(EReplyFeed.ERequest request, boolean mayRespond)
      Deprecated.
      Cancels the timer task associated with this request and sends a cancel complete reply.
      static boolean isETimerRunning()
      Deprecated.
      Returns true if the ETimer instance is running and false otherwise.
      boolean isRunning()
      Deprecated.
      Returns true if this ETimer is running and false if not.
      java.lang.String name()
      Deprecated.
      Returns ETimer name.
      void request​(EReplyFeed.ERequest request)
      Deprecated.
      Starts a timer task based on the given request.
      void shutdown()
      Deprecated.
      Cancels all running timers, stops the timer thread and retracts the timer service advertisement.
      static void startETimer()
      Deprecated.
      Starts the eBus timer service using the default timer name and the timer thread is not run as a daemon.
      static void startETimer​(boolean isDaemon)
      Deprecated.
      Starts the eBus timer service using the default timer name and the given daemon flag.
      static void startETimer​(java.lang.String name)
      Deprecated.
      Starts the eBus timer service for the given timer thread name.
      static void startETimer​(java.lang.String name, boolean isDaemon)
      Deprecated.
      Starts the eBus timer service for the given timer thread name and daemon flag.
      void startup()
      Deprecated.
      Puts the timer service request advertisement in place.
      static void stopETimer()
      Deprecated.
      Stops the eBus timer service, if running.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_TIMER_NAME

        public static final java.lang.String DEFAULT_TIMER_NAME
        Deprecated.
        The default timer name is "ETimer".
        See Also:
        Constant Field Values
      • TIMER_SUBJECT

        public static final java.lang.String TIMER_SUBJECT
        Deprecated.
        The advertised request message subject is "/eBusTimer".
        See Also:
        Constant Field Values
      • TIMER_KEY

        public static final EMessageKey TIMER_KEY
        Deprecated.
        The advertised request message key is TimerRequest:/eBusTimer.
    • Method Detail

      • name

        public java.lang.String name()
        Deprecated.
        Returns ETimer name.
        Specified by:
        name in interface EObject
        Returns:
        eBus object name.
      • startup

        public void startup()
        Deprecated.
        Puts the timer service request advertisement in place.
        Specified by:
        startup in interface EObject
        See Also:
        EObject.shutdown()
      • shutdown

        public void shutdown()
        Deprecated.
        Cancels all running timers, stops the timer thread and retracts the timer service advertisement.
        Specified by:
        shutdown in interface EObject
        See Also:
        EObject.startup()
      • request

        public void request​(EReplyFeed.ERequest request)
        Deprecated.
        Starts a timer task based on the given request. If the timer request is not valid, then sends a generic reply with a failed status and an explanation for the failure.

        Do not call this method. This method is part of the EReplier interface and is accessed by the eBus API only.

        Specified by:
        request in interface EReplier
        Parameters:
        request - the eBus request instance.
        See Also:
        EReplier.cancelRequest(EReplyFeed.ERequest, boolean)
      • cancelRequest

        public void cancelRequest​(EReplyFeed.ERequest request,
                                  boolean mayRespond)
        Deprecated.
        Cancels the timer task associated with this request and sends a cancel complete reply.

        Do not call this method. This method is part of the EReplier interface and is accessed by the eBus API only.

        Specified by:
        cancelRequest in interface EReplier
        Parameters:
        request - timer request being canceled.
        mayRespond - if true then send back a response.
        See Also:
        EReplier.request(EReplyFeed.ERequest)
      • isRunning

        public boolean isRunning()
        Deprecated.
        Returns true if this ETimer is running and false if not.
        Returns:
        true if eBus timer is running.
      • isETimerRunning

        public static boolean isETimerRunning()
        Deprecated.
        Returns true if the ETimer instance is running and false otherwise.
        Returns:
        true if the ETimer instance is running.
      • startETimer

        public static void startETimer()
        Deprecated.
        Starts the eBus timer service using the default timer name and the timer thread is not run as a daemon.
        Throws:
        java.lang.IllegalStateException - if the eBus timer service is already running.
      • startETimer

        public static void startETimer​(boolean isDaemon)
        Deprecated.
        Starts the eBus timer service using the default timer name and the given daemon flag.
        Parameters:
        isDaemon - true means that the timer thread is run as a daemon.
        Throws:
        java.lang.IllegalStateException - if the eBus timer service is already running.
      • startETimer

        public static void startETimer​(java.lang.String name)
        Deprecated.
        Starts the eBus timer service for the given timer thread name. The timer thread is not run as a daemon.
        Parameters:
        name - the timer thread name.
        Throws:
        java.lang.IllegalArgumentException - if name is either null or empty.
        java.lang.IllegalStateException - if the eBus timer service is already running.
      • startETimer

        public static void startETimer​(java.lang.String name,
                                       boolean isDaemon)
        Deprecated.
        Starts the eBus timer service for the given timer thread name and daemon flag.
        Parameters:
        name - timer thread name.
        isDaemon - if true, then the timer is a daemon thread.
        Throws:
        java.lang.IllegalArgumentException - if name is either null or empty.
        java.lang.IllegalStateException - if the eBus timer service is already running.
      • stopETimer

        public static void stopETimer()
        Deprecated.
        Stops the eBus timer service, if running. All running timer requests are canceled and requestors are informed.

        Does nothing if the timer service is not running.