|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.signal.AbstractSignalHandler net.sf.basedb.core.signal.DelegatingSignalHandler
public class DelegatingSignalHandler
A signal handler implementation that can delegate to other signal handlers, depending on which signal it receives. Multiple signal handlers may be registered for each signal. The order in which they are called is not specified, but it is probably different from the order they are registered.
Field Summary | |
---|---|
private Map<Signal,Set<SignalHandler>> |
handlers
Holds the registered signal handlers. |
private static Logger |
logger
Log signals processing. |
private List<Signal> |
received
List holding received signals. |
Constructor Summary | |
---|---|
DelegatingSignalHandler()
Create a new delegating signal handler. |
|
DelegatingSignalHandler(SignalHandler... handlers)
Create a new delegating signal handler and register the given handlers as delegates. |
Method Summary | |
---|---|
List<Signal> |
getReceivedSignals()
Get the list of received signals. |
Collection<Signal> |
getSupportedSignals()
Get all signals that are supported by this handler. |
void |
handleSignal(Signal signal)
Handler the given signal by invoking SignalHandler.handleSignal(Signal)
on each registered signal handler. |
boolean |
hasReceived(Signal signal)
Check if the given signal has been received by this signal handler. |
boolean |
hasReceivedSignals()
Check if any signals has been received by this handler. |
void |
registerSignalHandler(SignalHandler handler)
Register a signal handler to delegate to. |
boolean |
supports(Signal signal)
Check if at least one handler has been registered for the given signal. |
void |
unregisterSignalHandler(SignalHandler handler)
Unregister a signal handler. |
Methods inherited from class net.sf.basedb.core.signal.AbstractSignalHandler |
---|
addSignal, removeSignal |
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
private Map<Signal,Set<SignalHandler>> handlers
private final List<Signal> received
Constructor Detail |
---|
public DelegatingSignalHandler()
registerSignalHandler(SignalHandler)
.
public DelegatingSignalHandler(SignalHandler... handlers)
handlers
- An array with signal handlers that signal should
be delegated toMethod Detail |
---|
public Collection<Signal> getSupportedSignals()
SignalHandler
getSupportedSignals
in interface SignalHandler
getSupportedSignals
in class AbstractSignalHandler
public boolean supports(Signal signal)
supports
in interface SignalHandler
supports
in class AbstractSignalHandler
signal
- The signal to check
public void handleSignal(Signal signal)
SignalHandler.handleSignal(Signal)
on each registered signal handler. The order of the invokation is not
predictable.
signal
- The signal to handle
UnsupportedSignalException
- If no handler has been registered for the
given signalpublic void registerSignalHandler(SignalHandler handler)
handler
- The handler to registerpublic void unregisterSignalHandler(SignalHandler handler)
handler
- The handler to unregisterpublic boolean hasReceivedSignals()
public List<Signal> getReceivedSignals()
public boolean hasReceived(Signal signal)
signal
- The signal to check for
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |