2.17.2: 2011-06-17

Class LocalSignalReceiver

  extended by net.sf.basedb.core.signal.AbstractSignalReceiver
      extended by net.sf.basedb.core.signal.LocalSignalReceiver
All Implemented Interfaces:

public class LocalSignalReceiver
extends AbstractSignalReceiver

A signal receiver implementation that can receive signals from the local virtual machine only. The corresponding transporter class is LocalSignalTransporter.

Last modified
$Date: 2008-09-11 22:09:17 +0200 (Thu, 11 Sep 2008) $

Field Summary
private static Logger logger
          Log signals processing.
private  String receiverId
private static Map<String,LocalSignalReceiver> receivers
          Holds all registered signal receivers.
Constructor Summary
          Create a new local signal receiver.
Method Summary
 void close(int wait)
          Close this signal receiver.
static LocalSignalReceiver getSignalReceiver(String id)
          Get a signal receiver with a given ID.
 Class<? extends SignalTransporter> getSignalTransporterClass()
          Get the signal transporter class that should be used to send signals to this receiver.
 void init(String params)
          Initialise the signal receiver.
 void send(String handlerId, Signal signal)
          Send the signal to a registered handler.
Methods inherited from class net.sf.basedb.core.signal.AbstractSignalReceiver
getGlobalSignalId, getLocalSignalHandlerId, getReceiverId, getSignalHandler, processSignalMessage, registerSignalHandler, sendToAll, sendToAll, unregisterSignalHandler
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


private static final Logger logger
Log signals processing.


private static Map<String,LocalSignalReceiver> receivers
Holds all registered signal receivers.


private String receiverId
Constructor Detail


public LocalSignalReceiver()
Create a new local signal receiver. Before it can be used it must be initialised with init(String).

Method Detail


public static LocalSignalReceiver getSignalReceiver(String id)
Get a signal receiver with a given ID.

id - The ID of the signal receiver
A signal receiver, or null if no receiver with the given ID exists.


public void init(String params)
Initialise the signal receiver. The given parameter becomes the ID of the receiver. When this method return the signal receiver is ready to register signal handlers and receive signals.

Specified by:
init in interface SignalReceiver
init in class AbstractSignalReceiver
params - The ID of the signal receiver, needed if the default ID generation should be used


public void close(int wait)
Description copied from class: AbstractSignalReceiver
Close this signal receiver. If a subclass overrides this method it should call 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.

Specified by:
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 waiting


public Class<? extends SignalTransporter> getSignalTransporterClass()
Description copied from interface: SignalReceiver
Get the signal transporter class that should be used to send signals to this receiver.



public void send(String handlerId,
                 Signal signal)
Send the signal to a registered handler. If no handler with the given ID is found this method does nothing. The signal will be processed by the handler in the current thread.

handlerId - The ID of a registered handler
signal - The signal to send

2.17.2: 2011-06-17