org.jlab.coda.cMsg.RCDomain
Class RunControl

java.lang.Object
  extended by org.jlab.coda.cMsg.cMsgDomainAdapter
      extended by org.jlab.coda.cMsg.RCDomain.RunControl
All Implemented Interfaces:
cMsgDomainInterface

public class RunControl
extends cMsgDomainAdapter

This class implements a cMsg client in the RunControl (or RC) domain.

Version:
1.0
Author:
Carl Timmer

Field Summary
 java.util.Set<cMsgSubscription> subscriptions
          Collection of all of this client's message subscriptions which are cMsgSubscription objects.
 
Fields inherited from class org.jlab.coda.cMsg.cMsgDomainAdapter
connected, description, domain, host, name, receiving, shutdownHandler, UDL, UDLremainder
 
Constructor Summary
RunControl()
          Constructor.
 
Method Summary
 void connect()
          Method to connect to the codaComponent server from this client.
 void disconnect()
          Method to close the connection to the domain server.
 void send(cMsgMessage message)
          Method to send a message to the domain server for further distribution.
 java.lang.Object subscribe(java.lang.String subject, java.lang.String type, cMsgCallbackInterface cb, java.lang.Object userObj)
          Method to subscribe to receive messages of a subject and type from the domain server.
 void unsubscribe(java.lang.Object obj)
          Method to unsubscribe a previous subscription to receive messages of a subject and type from the domain server.
 
Methods inherited from class org.jlab.coda.cMsg.cMsgDomainAdapter
flush, getDescription, getDomain, getHost, getName, getShutdownHandler, getString, getUDL, getUDLRemainder, isConnected, isReceiving, monitor, sendAndGet, setDescription, setName, setShutdownHandler, setUDL, setUDLRemainder, shutdownClients, shutdownServers, start, stop, subscribeAndGet, syncSend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

subscriptions

public java.util.Set<cMsgSubscription> subscriptions
Collection of all of this client's message subscriptions which are cMsgSubscription objects. This set is synchronized. A client is either a regular client or a bridge but not both. That means it does not matter that a bridge client will add namespace data to the stored subscription but a regular client will not.

Constructor Detail

RunControl

public RunControl()
           throws cMsgException
Constructor.

Throws:
cMsgException
Method Detail

connect

public void connect()
             throws cMsgException
Method to connect to the codaComponent server from this client.

Specified by:
connect in interface cMsgDomainInterface
Overrides:
connect in class cMsgDomainAdapter
Throws:
cMsgException - if there are problems parsing the UDL or communication problems with the server(s)

disconnect

public void disconnect()
Method to close the connection to the domain server. This method results in this object becoming functionally useless.

Specified by:
disconnect in interface cMsgDomainInterface
Overrides:
disconnect in class cMsgDomainAdapter

send

public void send(cMsgMessage message)
          throws cMsgException
Method to send a message to the domain server for further distribution.

Specified by:
send in interface cMsgDomainInterface
Overrides:
send in class cMsgDomainAdapter
Parameters:
message - message to send
Throws:
cMsgException - if there are communication problems with the server; subject and/or type is null

subscribe

public java.lang.Object subscribe(java.lang.String subject,
                                  java.lang.String type,
                                  cMsgCallbackInterface cb,
                                  java.lang.Object userObj)
                           throws cMsgException
Method to subscribe to receive messages of a subject and type from the domain server. The combination of arguments must be unique. In other words, only 1 subscription is allowed for a given set of subject, type, callback, and userObj. Note about the server failing and an IOException being thrown. All existing subscriptions are resubscribed on the new failover server by the keepAlive thread. However, this routine will recover from an IO error during the subscribe itself if the failover is successful.

Specified by:
subscribe in interface cMsgDomainInterface
Overrides:
subscribe in class cMsgDomainAdapter
Parameters:
subject - message subject
type - message type
cb - callback object whose single method is called upon receiving a message of subject and type
userObj - any user-supplied object to be given to the callback method as an argument
Returns:
handle object to be used for unsubscribing
Throws:
cMsgException - if the callback, subject and/or type is null or blank; an identical subscription already exists; there are communication problems with the server

unsubscribe

public void unsubscribe(java.lang.Object obj)
                 throws cMsgException
Method to unsubscribe a previous subscription to receive messages of a subject and type from the domain server. Note about the server failing and an IOException being thrown. To have "unsubscribe" make sense on the failover server, we must wait until all existing subscriptions have been successfully resubscribed on the new server.

Specified by:
unsubscribe in interface cMsgDomainInterface
Overrides:
unsubscribe in class cMsgDomainAdapter
Parameters:
obj - the object "handle" returned from a subscribe call
Throws:
cMsgException - if there are communication problems with the server; object arg is null