SIGNAL
- type of signal that this node works withpublic class SignalRelay<SIGNAL>
extends java.lang.Object
The class is thread-safe.
This class is useful for a shutdown strategy, when several resources should be taken down together, but there are no single authority to manage it. E.g. in a client-medium-server threesome each part can initiate shutdown.
Nodes of different signal system can be bound using SignalRelay.SignalConverter
.
Modifier and Type | Class and Description |
---|---|
static class |
SignalRelay.AlreadySignalledException |
static interface |
SignalRelay.Callback<S>
An interface to notify a user about a received signal.
|
static interface |
SignalRelay.SignalConverter<FROM,TO>
A converter that translates signals from one type to another so that unrelated resources
could co-work.
|
Constructor and Description |
---|
SignalRelay(SignalRelay.Callback<SIGNAL> callback) |
Modifier and Type | Method and Description |
---|---|
<OPPOSITE> void |
bind(SignalRelay<OPPOSITE> peer,
SignalRelay.SignalConverter<SIGNAL,OPPOSITE> toPeerConverter,
SignalRelay.SignalConverter<OPPOSITE,SIGNAL> fromPeerConverter)
Binds this node to a peer node.
|
static <T> SignalRelay<T> |
create(SignalRelay.Callback<T> callback) |
SIGNAL |
getReceivedSignal() |
boolean |
isSignalled() |
void |
sendSignal(SIGNAL signal,
java.lang.Exception cause) |
public SignalRelay(SignalRelay.Callback<SIGNAL> callback)
public static <T> SignalRelay<T> create(SignalRelay.Callback<T> callback)
public void sendSignal(SIGNAL signal, java.lang.Exception cause)
public boolean isSignalled()
public SIGNAL getReceivedSignal()
public <OPPOSITE> void bind(SignalRelay<OPPOSITE> peer, SignalRelay.SignalConverter<SIGNAL,OPPOSITE> toPeerConverter, SignalRelay.SignalConverter<OPPOSITE,SIGNAL> fromPeerConverter) throws SignalRelay.AlreadySignalledException
OPPOSITE
- type of signal the peer node works withtoPeerConverter
- a signal converter that is used when sending signal or nullfromPeerConverter
- a signal converter that is used when receiving signal or nullSignalRelay.AlreadySignalledException
- when binding to node that already has a signalCopyright (c) IBM Corp. and others 2000, 2016. All Rights Reserved.