public class BusApplicationLayer extends Object
Each is bound to a subsystem.
This class is meant to be subclassed if there is a need to setup complex correlations between messages (or more generally for "application layer" concerns)
beware ThreadLocal objects may be changed in future releases: they may be moved to Context objects carried through thread creations.| Modifier and Type | Class and Description |
|---|---|
protected class |
BusApplicationLayer.ForwarderToCommand
instances of this class will forward commands coming from the transport layer
to the registered CommandListener.
|
protected class |
BusApplicationLayer.ForwarderToLog
instances of this class will forward directly log messages to a log listener
|
class |
BusApplicationLayer.ForwarderToStatus
instances of this class will forward directly status messages to statuslistener
|
| Modifier and Type | Field and Description |
|---|---|
protected BusMessagingLayer |
busMessagingLayer |
protected ThreadLocal<Command> |
localCommand |
protected ThreadLocal<String> |
localCorrelID |
protected ThreadLocal<String> |
localOrigin |
protected static org.lsst.ccs.utilities.logging.Logger |
log |
protected String |
subsystemName |
| Constructor and Description |
|---|
BusApplicationLayer(String subsystemName,
BusMessagingLayer busMessagingLayer)
creates an entry point to communication for the subsystem.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCommandListener(CommandListener l)
registers a CommandListener (in fact a ForwarderToCommand to the underlying transport)
|
void |
addLogListener(LogListener l)
registers a LogListener (in fact a ForwarderToLog to the underlying transport)
|
void |
addStatusListener(StatusListens l)
registers a StatusListener (in fact a ForwarderToStatus to the underlying transport)
|
void |
close()
closes the underlying transport layer, stops the listening threads,
after this call all other sending calls will fail.
|
String |
getToken() |
protected String[] |
parseDestination(String destination)
utility method: parse the destination string in Commands.
|
void |
registerToCommand()
registers current subsystem to the Command bus
|
void |
registerToLog()
registers current subsystem to the logging bus
|
void |
registerToStatus()
registers current subsystem to the Status bus
|
void |
removeCommandListener(CommandListener l)
removes a CommandListener: since this command is based on strict identity the listener should be exactly the same
as the one registered.
|
void |
removeLogListener(LogListener l) |
void |
removeStatusListener(StatusListens l) |
void |
reply(CommandAckOrReply cmd)
sends a reply or an ack responding to a command.
|
void |
sendCommand(Command cmd)
sends a command message to all destinations.
|
void |
sendLogEvent(LogEvent evt)
broadcasts a log message.
|
void |
sendStatus(Status status)
broadcasts a status message.
|
protected final String subsystemName
protected final BusMessagingLayer busMessagingLayer
protected static org.lsst.ccs.utilities.logging.Logger log
protected ThreadLocal<String> localCorrelID
protected ThreadLocal<String> localOrigin
protected ThreadLocal<Command> localCommand
public BusApplicationLayer(String subsystemName, BusMessagingLayer busMessagingLayer)
subsystemName - rules of naming applybusMessagingLayer - transport layerNullPointerException - if busMessagingLayer is nullpublic String getToken()
public void registerToCommand()
throws IOException
IOExceptionpublic void registerToStatus()
throws IOException
IOExceptionpublic void registerToLog()
throws IOException
IOExceptionprotected String[] parseDestination(String destination)
destination - public void sendCommand(Command cmd) throws IOException
cmd - IOExceptionDestinationsException - may be thrown if the transport layer is unable to find some of the
destination and has no broadcast policy in this case.for another way to signal
destinations exceptionspublic void sendStatus(Status status) throws IOException
status - IOExceptionpublic void sendLogEvent(LogEvent evt) throws IOException
evt - IOExceptionpublic void reply(CommandAckOrReply cmd) throws IOException
cmd - IOExceptionDestinationsException - may be thrown if the transport layer is unable to find some of the
destination and has no broadcast policy in this case.for another way to signal
destinations exceptionspublic void addCommandListener(CommandListener l)
l - public void removeCommandListener(CommandListener l)
l - public void addStatusListener(StatusListens l)
l - public void removeStatusListener(StatusListens l)
public void addLogListener(LogListener l)
l - public void removeLogListener(LogListener l)
public void close()
Copyright © 2014 LSST. All Rights Reserved.