public class LocalSignalReceiver extends AbstractSignalReceiver
LocalSignalTransporter
.Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
logger
Log signals processing.
|
private java.lang.String |
receiverId |
private static java.util.Map<java.lang.String,LocalSignalReceiver> |
receivers
Holds all registered signal receivers.
|
Constructor and Description |
---|
LocalSignalReceiver()
Create a new local signal receiver.
|
Modifier and Type | Method and Description |
---|---|
void |
close(int wait)
Close this signal receiver.
|
static LocalSignalReceiver |
getSignalReceiver(java.lang.String id)
Get a signal receiver with a given ID.
|
java.lang.Class<? extends SignalTransporter> |
getSignalTransporterClass()
Get the signal transporter class that should be used to
send signals to this receiver.
|
void |
init(java.lang.String params)
Initialise the signal receiver.
|
void |
send(java.lang.String handlerId,
Signal signal)
Send the signal to a registered handler.
|
getGlobalSignalId, getLocalSignalHandlerId, getReceiverId, getSignalHandler, processSignalMessage, registerSignalHandler, sendToAll, unregisterSignalHandler
private static final org.slf4j.Logger logger
private static java.util.Map<java.lang.String,LocalSignalReceiver> receivers
private java.lang.String receiverId
public LocalSignalReceiver()
init(String)
.public static LocalSignalReceiver getSignalReceiver(java.lang.String id)
id
- The ID of the signal receiverpublic void init(java.lang.String params)
init
in interface SignalReceiver
init
in class AbstractSignalReceiver
params
- The ID of the signal receiver, needed if the default
ID generation should be usedpublic void close(int wait)
AbstractSignalReceiver
super.close()
if it wants to
use the default shutdown notification to signal handlers. This
implementation will start a separate notification thread that first sends
the Signal.SHUTDOWN
signal to all registered handlers, and then
Signal.ABORT
signal to all that are still alive after the shutdown signal.
The current thread will wait at most the given time. If the number of registered handlers
goes down to 0 before the time has ended the current thread will be awakened
so it can continue. Note that the notification thread will usually finish in
a short time, but it may take longer for all worker thread of each job to
react to the signal.close
in interface SignalReceiver
close
in class AbstractSignalReceiver
wait
- Number of milliseconds to wait for registered jobs to abort,
use a negative value to disable notification, and 0 to disable waitingpublic java.lang.Class<? extends SignalTransporter> getSignalTransporterClass()
SignalReceiver
LocalSignalTransporter
public void send(java.lang.String handlerId, Signal signal)
handlerId
- The ID of a registered handlersignal
- The signal to send