Interface Service

All Known Implementing Classes:
AbstractServer, ImapServer, Pop3Server, SmtpServer

public interface Service
Generic lifecycle handling of a service.

Used by email protocol specific services, such as SmtpServer.

Since:
2005
Author:
Wael Chatila
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if service is up and running.
    void
    Starts the service in the background as a new thread.
    void
    Stops the service.
    void
    stopService(long timeoutInMs)
    Stops the service.
    boolean
    waitTillRunning(long timeoutInMs)
    Waits till service is up or timeout was reached.
  • Method Details

    • startService

      void startService()
      Starts the service in the background as a new thread.

      You can use isRunning() and waitTillRunning(long) to check if service is up.

    • stopService

      void stopService()
      Stops the service.

      Blocks till the service stopped.

    • stopService

      void stopService(long timeoutInMs)
      Stops the service.

      Blocks till the service stopped.

      If a timeout is given and the service has still not gracefully been stopped after timeout ms the service is stopped by force.

      Parameters:
      timeoutInMs - the timeout in milliseconds
    • isRunning

      boolean isRunning()
      Checks if service is up and running.
      Returns:
      true, if running.
    • waitTillRunning

      boolean waitTillRunning(long timeoutInMs) throws InterruptedException
      Waits till service is up or timeout was reached.
      Parameters:
      timeoutInMs - the timeout in milliseconds
      Returns:
      true, if running otherwise false if timeout was reached.
      Throws:
      InterruptedException - if interrupted while waiting.