Class WaitService

java.lang.Object
com.adaptris.core.ServiceImp
com.adaptris.core.services.WaitService
All Implemented Interfaces:
AdaptrisComponent, ComponentLifecycle, ComponentLifecycleExtension, MessageEventGenerator, Service, StateManagedComponent

@ComponentProfile(summary="Delay processing", tag="service") public class WaitService extends ServiceImp

Implementation of Service for testing which sleeps for a configurable period.

In the adapter configuration file this class is aliased as wait-service which is the preferred alternative to the fully qualified classname when building your configuration.

  • Constructor Details

    • WaitService

      public WaitService()

      Creates a new instance.

    • WaitService

      public WaitService(TimeInterval wait)
    • WaitService

      public WaitService(TimeInterval wait, Boolean randomize)
    • WaitService

      public WaitService(String uniqueId)
  • Method Details

    • doService

      public void doService(AdaptrisMessage msg) throws ServiceException

      Waits for the configured number of milliseconds.

      Parameters:
      msg - the message to apply service to
      Throws:
      ServiceException - wrapping any underlying Exceptions
    • initService

      protected void initService()
      Specified by:
      initService in class ServiceImp
    • closeService

      protected void closeService()
      Specified by:
      closeService in class ServiceImp
    • waitMs

      protected long waitMs()
    • getWaitInterval

      public TimeInterval getWaitInterval()
    • setWaitInterval

      public void setWaitInterval(TimeInterval interval)
      Set how long to wait for.
      Parameters:
      interval - if not specified then the default is 20 seconds.
    • prepare

      public void prepare() throws CoreException
      Description copied from interface: ComponentLifecycleExtension
      Prepare for initialisation.
      Throws:
      CoreException
    • getRandomize

      public Boolean getRandomize()
    • setRandomize

      public void setRandomize(Boolean b)
      Set to true to randomize the wait time between 0 and the value specified by setWaitInterval(TimeInterval)
      Parameters:
      b - default null (false)
    • randomizeWait

      protected boolean randomizeWait()
    • getExceptionOnInterrupt

      public Boolean getExceptionOnInterrupt()
      Returns:
      the exceptionOnInterupt
    • setExceptionOnInterrupt

      public void setExceptionOnInterrupt(Boolean b)
      Whether or not to throw an exception if an InterruptedException happens.
      Parameters:
      b - the exceptionOnInterupt to set
      Since:
      3.6.6