Interface SignalReceiver

All Known Implementing Classes:
AbstractSignalReceiver, AgentSignalReceiver, LocalSignalReceiver, SimpleSignalProgressReporter, SocketSignalReceiver

public interface SignalReceiver
A signal receiver is a class that knows how to receive a Signal from a SignalTransporter and how to distribute this to a SignalHandler. Signal receivers are needed to decouple the actual signal handling from the transportation of signals. A signal receiver implementation usually comes in pair with a singal transporter implementation. See, for example, the SocketSignalReceiver and SocketSignalTransporter implementations which uses network sockets to transport signals.

Signal receivers must be thread safe since a single receiver may be used to handle signals for multiple jobs at the same time.

Version:
2.6
Author:
nicklas
See Also:
Last modified
$Date: 2011-03-16 12:48:47 +0100 (on, 16 mar 2011) $
  • Method Details

    • init

      void init(String params)
      Initialise the signal receiver. The syntax and meaning of the parameter sent to it is implementation-dependant. When this method return the signal receiver is ready to register signal handlers and receive signals.
      Parameters:
      params - Parameters needed to initialise the receiver
    • close

      void close(int wait)
      Close the receiver. The receiver should close and cleanup any opened resources, unregister itself if neccesary and stop listening for signals.
      Parameters:
      wait - If the value is zero or positive, the Signal.ABORT should be sent to all registered signal handlers. The signal receiver should then wait at most the specified number of milliseconds for all signal handlers to get unregistered. If the timeout expires before all signal handlers has processed the signal, the signal receiver should continue it's shutdown.
    • getSignalTransporterClass

      Class<? extends SignalTransporter> getSignalTransporterClass()
      Get the signal transporter class that should be used to send signals to this receiver.
      Returns:
      A class objects that must be a subclass of SignalTransporter
    • registerSignalHandler

      String registerSignalHandler(SignalHandler handler)
      Register a signal handler with this receiver. The receiver should return a string, that, when used with the SignalTransporter.init(String) method lets the transporter know how to send a signal to the specific handler. The SocketSignalReceiver will for example, include the IP number and port the transporter should connect to and a unique ID that allows the receiver to locate the signal hander the signal is intended for. The format of the ID is implementation specific and need only to be understandable by the receiver and transporter implementations.
      Parameters:
      handler - The signal handler that should receive signals through this receiver
      Returns:
      A string that allows a transporter instance locate and send a signal to the given signal handler
      See Also:
    • unregisterSignalHandler

      void unregisterSignalHandler(SignalHandler handler)
      Unregister a signal handler from this receiever. After this method returns, the receiver must not send any more signals to the specified handler.
      Parameters:
      handler - The handler to unregister
    • sendToAll

      void sendToAll(SignalSender sender)
      Let the signal sender send one or more signals to all registered signal handlers on this reciever.
      Parameters:
      sender - A signal sender implementation
      Since:
      2.16