Class AbstractActiveService


  • public abstract class AbstractActiveService
    extends Object
    Base class for services that frequently run some action in a separate thread in the background.
    Author:
    Kai Kreuzer - Initial contribution
    • Field Detail

      • shutdown

        protected boolean shutdown
        indicates that the background thread will shutdown after the current execution cycle.
    • Constructor Detail

      • AbstractActiveService

        public AbstractActiveService()
    • Method Detail

      • activate

        public void activate()
      • deactivate

        public void deactivate()
      • start

        protected void start()
        Takes care about starting the refresh thread. It creates a new RefreshThread if no instance exists.
      • shutdown

        public void shutdown()
        Gracefully shuts down the refresh background thread. It will shuts down after the current execution cycle.
      • interrupt

        public void interrupt()
        Interrupts the refresh thread immediately.
      • isRunning

        public boolean isRunning()
      • isProperlyConfigured

        public final boolean isProperlyConfigured()
        Returns:
        true if this binding is configured properly which means that all necessary data is available
      • setProperlyConfigured

        public void setProperlyConfigured​(boolean properlyConfigured)
        Used to define whether this binding is fully configured so that it can be activated and used. Note that the implementation will automatically start the active service if true is passed as a parameter.
        Parameters:
        properlyConfigured -
      • execute

        protected abstract void execute()
        The working method which is called by the refresh thread frequently. Developers should put their binding code here.
      • getRefreshInterval

        protected abstract long getRefreshInterval()
        Returns the refresh interval to be used by the RefreshThread between to calls of the execute method.
        Returns:
        the refresh interval
      • getName

        protected abstract String getName()
        Returns the name of the Refresh thread.
        Returns:
        the name of the refresh thread.