- All Known Implementing Classes:
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
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,
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.
Modifier and Type Method Description
(int wait)Close the receiver.
Class<? extends SignalTransporter>
()Get the signal transporter class that should be used to send signals to this receiver.
String params)(Initialise the signal receiver.
SignalHandler handler)(Register a signal handler with this receiver.
SignalSender sender)(Let the signal sender send one or more signals to all registered signal handlers on this reciever.
SignalHandler handler)(Unregister a signal handler from this receiever.
initvoid 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.
params- Parameters needed to initialise the receiver
closevoid close(int wait)Close the receiver. The receiver should close and cleanup any opened resources, unregister itself if neccesary and stop listening for signals.
wait- If the value is zero or positive, the
Signal.ABORTshould 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.
getSignalTransporterClassGet the signal transporter class that should be used to send signals to this receiver.
- A class objects that must be a subclass of
registerSignalHandlerRegister 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
SocketSignalReceiverwill 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.
handler- The signal handler that should receive signals through this receiver
- A string that allows a transporter instance locate and send a signal to the given signal handler
- See Also:
unregisterSignalHandlervoid 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.
handler- The handler to unregister
sendToAllvoid sendToAll(SignalSender sender)Let the signal sender send one or more signals to all registered signal handlers on this reciever.
sender- A signal sender implementation