org.jlab.coda.cMsg.CADomain
Class CA

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

public class CA
extends cMsgDomainAdapter

This class implements a client in the cMsg Channel Access (CA) domain. UDL: cMsg:CA://channelName?addr_list=list. where addr_list specifies the UDP broadcast address list.

Version:
1.0
Author:
Elliott Wolin

Field Summary
 
Fields inherited from class org.jlab.coda.cMsg.cMsgDomainAdapter
connected, description, domain, host, name, receiving, shutdownHandler, UDL, UDLremainder
 
Constructor Summary
CA()
          Constructor for CADomain.
 
Method Summary
 void connect()
          Connects to channel after parsing UDL.
 void disconnect()
          Method to close the connection to the domain server.
 void flush(int timeout)
          Method to force cMsg client to send pending communications with domain server.
 void send(cMsgMessage msg)
          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.
 cMsgMessage subscribeAndGet(java.lang.String subject, java.lang.String type, int timeout)
          This method does two separate things depending on the specifics of message in the argument.
 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
getDescription, getDomain, getHost, getName, getShutdownHandler, getString, getUDL, getUDLRemainder, isConnected, isReceiving, monitor, sendAndGet, setDescription, setName, setShutdownHandler, setUDL, setUDLRemainder, shutdownClients, shutdownServers, start, stop, syncSend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CA

public CA()
   throws cMsgException
Constructor for CADomain.

Throws:
cMsgException - if domain in not implemented or there are problems
Method Detail

connect

public void connect()
             throws cMsgException
Connects to channel after parsing UDL.

Specified by:
connect in interface cMsgDomainInterface
Overrides:
connect in class cMsgDomainAdapter
Throws:
cMsgException - if there are communication problems

disconnect

public void disconnect()
                throws cMsgException
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
Throws:
cMsgException - always throws an exception since this is a dummy implementation

send

public void send(cMsgMessage msg)
          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:
msg - message
Throws:
cMsgException - always throws an exception since this is a dummy implementation

flush

public void flush(int timeout)
           throws cMsgException
Method to force cMsg client to send pending communications with domain server.

Specified by:
flush in interface cMsgDomainInterface
Overrides:
flush in class cMsgDomainAdapter
Parameters:
timeout - time in milliseconds to wait for completion
Throws:
cMsgException - always throws an exception since this is a dummy implementation

subscribeAndGet

public cMsgMessage subscribeAndGet(java.lang.String subject,
                                   java.lang.String type,
                                   int timeout)
                            throws cMsgException
This method does two separate things depending on the specifics of message in the argument. If the message to be sent has its "getRequest" field set to be true using cMsgMessage.isGetRequest(), then the message is sent as it would be in the send(org.jlab.coda.cMsg.cMsgMessage) method. The server notes the fact that a response to it is expected, and sends it to all subscribed to its subject and type. When a marked response is received from a client, it sends that first response back to the original sender regardless of its subject or type. In a second usage, if the message did NOT set its "getRequest" field to be true, then the server grabs the first incoming message of the requested subject and type and sends that to the original sender in response to the get.

Specified by:
subscribeAndGet in interface cMsgDomainInterface
Overrides:
subscribeAndGet in class cMsgDomainAdapter
Parameters:
subject - subject of message desired from server
type - type of message desired from server
timeout - time in milliseconds to wait for a reponse message
Returns:
response message
Throws:
cMsgException - always throws an exception since this is a dummy implementation

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.

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 - always throws an exception since this is a dummy implementation

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. Since many subscriptions may be made to the same subject and type values, but with different callbacks, the callback must be specified so the correct subscription can be removed.

Specified by:
unsubscribe in interface cMsgDomainInterface
Overrides:
unsubscribe in class cMsgDomainAdapter
Parameters:
obj - the object "handle" returned from a subscribe call
Throws:
cMsgException - always throws an exception since this is a dummy implementation