Module id.xfunction

Class LazyService

Object
LazyService
All Implemented Interfaces:
AutoCloseable

public abstract class LazyService extends Object implements AutoCloseable
Simple implementation of service lifecycle.

Lifecycle phases:

  • not started
  • started
  • stopped
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Stops the service if it is not yet stopped (idempotent operation).
    protected abstract void
    Called only once during service lifetime.
    protected abstract void
    Called only once during service lifetime when no exception is thrown.
    void
    Starts the service if it is not yet started (idempotent operation).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LazyService

      public LazyService()
  • Method Details

    • startLazy

      public void startLazy()
      Starts the service if it is not yet started (idempotent operation).
    • onStart

      protected abstract void onStart()
      Called only once during service lifetime when no exception is thrown. If it throws an exception then service will not be started and can be retried later again until it finishes without exceptions.
    • onClose

      protected abstract void onClose()
      Called only once during service lifetime. Service will be marked as closed even if exception is thrown
    • close

      public void close()
      Stops the service if it is not yet stopped (idempotent operation).
      Specified by:
      close in interface AutoCloseable