Class AbstractConcurrentService

java.lang.Object
ru.progrm_jarvis.javacommons.service.AbstractConcurrentService
All Implemented Interfaces:
AutoCloseable, Service

public abstract class AbstractConcurrentService extends Object implements Service
Abstract implementation of Service making its concurrent.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final @NonNull AtomicBoolean
    Flag indicating whether this service is enabled
    protected final @NonNull Lock
    Lock used for synchronizing lifecycle operations
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractConcurrentService(@NonNull Lock lifecycleLock)
    Creates a new abstract concurrent service using the given lock.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Disables this service, doing nothing if this service is already disabled.
    void
    Enables this service, doing nothing if this service is already enabled.
    protected abstract void
    Actually disables this service.
    protected abstract void
    Actually enables this service.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface ru.progrm_jarvis.javacommons.service.Service

    close
  • Field Details

    • enabled

      @NonNull protected final @NonNull AtomicBoolean enabled
      Flag indicating whether this service is enabled
    • lifecycleLock

      @NonNull protected final @NonNull Lock lifecycleLock
      Lock used for synchronizing lifecycle operations
  • Constructor Details

    • AbstractConcurrentService

      protected AbstractConcurrentService(@NonNull @NonNull Lock lifecycleLock)
      Creates a new abstract concurrent service using the given lock.
      Parameters:
      lifecycleLock - lock used for synchronizing lifecycle operations
  • Method Details

    • enable

      public void enable()
      Description copied from interface: Service
      Enables this service, doing nothing if this service is already enabled.
      Specified by:
      enable in interface Service
    • onEnable

      protected abstract void onEnable()
      Actually enables this service. This should not be manually synchronized as it is called by an already concurrent enable().
    • disable

      public void disable()
      Description copied from interface: Service
      Disables this service, doing nothing if this service is already disabled.
      Specified by:
      disable in interface Service
    • onDisable

      protected abstract void onDisable()
      Actually disables this service. This should not be manually synchronized as it is called by an already concurrent disable() ()}.