org.jlab.coda.cMsg
Class cMsgSubdomainAdapter

java.lang.Object
  extended by org.jlab.coda.cMsg.cMsgSubdomainAdapter
All Implemented Interfaces:
cMsgSubdomainInterface
Direct Known Subclasses:
CA, cMsg, Database, Dummy, FileQueue, LogFile, Queue, SmartSockets, TcpServer

public class cMsgSubdomainAdapter
extends java.lang.Object
implements cMsgSubdomainInterface

This class provides a very basic (non-functional/dummy) implementation of the cMsgSubdomainInterface interface. This class is used by a domain server to respond to client demands. It contains some methods that hide the details of communication with the client. A fully implementated subclass of this class must handle all communication with a particular subdomain (such as SmartSockets or JADE agents).

Understand that each client using cMsg will have its own handler object from either an implemenation of the cMsgSubdomainInterface interface or a subclass of this class. One client may concurrently use the same cMsgHandleRequest object; thus, implementations must be thread-safe. Furthermore, when the name server shuts dowm, the method handleServerShutdown may be executed more than once for the same reason.

Version:
1.0
Author:
Carl Timmer

Constructor Summary
cMsgSubdomainAdapter()
           
 
Method Summary
 void handleClientShutdown()
          Method to handle a client or domain server down.
 void handleKeepAlive()
          Method to handle keepalive sent by domain client checking to see if the domain server socket is still up.
 void handleSendAndGetRequest(cMsgMessageFull message)
          Method to synchronously get a single message from a receiver by sending out a message to be responded to.
 void handleSendRequest(cMsgMessageFull message)
          Method to handle message sent by domain client.
 void handleShutdownClientsRequest(java.lang.String client, boolean includeMe)
          Method to handle request to shutdown clients sent by domain client.
 void handleSubscribeAndGetRequest(java.lang.String subject, java.lang.String type, int id)
          Method to synchronously get a single message from the server for a one-time subscription of a subject and type.
 void handleSubscribeRequest(java.lang.String subject, java.lang.String type, int id)
          Method to handle subscribe request sent by domain client.
 int handleSyncSendRequest(cMsgMessageFull message)
          Method to handle message sent by domain client in synchronous mode.
 void handleUnSendAndGetRequest(int id)
          Method to handle remove sendAndGet request sent by domain client (hidden from user).
 void handleUnsubscribeAndGetRequest(java.lang.String subject, java.lang.String type, int id)
          Method to handle remove subscribeAndGet request sent by domain client (hidden from user).
 void handleUnsubscribeRequest(java.lang.String subject, java.lang.String type, int id)
          Method to handle unsubscribe request sent by domain client.
 boolean hasSend()
          Method to tell if the "send" cMsg API function is implemented by this interface implementation in the handleSendRequest(org.jlab.coda.cMsg.cMsgMessageFull) method.
 boolean hasSendAndGet()
          Method to tell if the "sendAndGet" cMsg API function is implemented by this interface implementation in the handleSendAndGetRequest(org.jlab.coda.cMsg.cMsgMessageFull) method.
 boolean hasShutdown()
          Method to tell if the "shutdown" cMsg API function is implemented by this interface implementation in the handleShutdownClientsRequest(java.lang.String, boolean) method.
 boolean hasSubscribe()
          Method to tell if the "subscribe" cMsg API function is implemented by this interface implementation in the handleSubscribeRequest(java.lang.String, java.lang.String, int) method.
 boolean hasSubscribeAndGet()
          Method to tell if the "subscribeAndGet" cMsg API function is implemented by this interface implementation in the handleSubscribeAndGetRequest(java.lang.String, java.lang.String, int) method.
 boolean hasSyncSend()
          Method to tell if the "syncSend" cMsg API function is implemented by this interface implementation in the handleSyncSendRequest(org.jlab.coda.cMsg.cMsgMessageFull) method.
 boolean hasUnsubscribe()
          Method to tell if the "unsubscribe" cMsg API function is implemented by this interface implementation in the handleUnsubscribeRequest(java.lang.String, java.lang.String, int) method.
 void registerClient(cMsgClientInfo info)
          Method to register domain client.
 void setMessageDeliverer(cMsgDeliverMessageInterface deliverer)
          Method to give the subdomain handler on object able to deliver messages to the client.
 void setUDLRemainder(java.lang.String UDLRemainder)
          Method to give the subdomain handler the appropriate part of the UDL the client used to talk to the domain server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

cMsgSubdomainAdapter

public cMsgSubdomainAdapter()
Method Detail

setUDLRemainder

public void setUDLRemainder(java.lang.String UDLRemainder)
                     throws cMsgException
Method to give the subdomain handler the appropriate part of the UDL the client used to talk to the domain server.

Specified by:
setUDLRemainder in interface cMsgSubdomainInterface
Parameters:
UDLRemainder - last part of the UDL appropriate to the subdomain handler
Throws:
cMsgException

setMessageDeliverer

public void setMessageDeliverer(cMsgDeliverMessageInterface deliverer)
                         throws cMsgException
Method to give the subdomain handler on object able to deliver messages to the client.

Specified by:
setMessageDeliverer in interface cMsgSubdomainInterface
Parameters:
deliverer - object able to deliver messages to the client
Throws:
cMsgException

registerClient

public void registerClient(cMsgClientInfo info)
                    throws cMsgException
Method to register domain client.

Specified by:
registerClient in interface cMsgSubdomainInterface
Parameters:
info - information about client
Throws:
cMsgException

handleSendRequest

public void handleSendRequest(cMsgMessageFull message)
                       throws cMsgException
Method to handle message sent by domain client.

Specified by:
handleSendRequest in interface cMsgSubdomainInterface
Parameters:
message - message from sender
Throws:
cMsgException

handleSyncSendRequest

public int handleSyncSendRequest(cMsgMessageFull message)
                          throws cMsgException
Method to handle message sent by domain client in synchronous mode. It requries an integer response from the subdomain handler.

Specified by:
handleSyncSendRequest in interface cMsgSubdomainInterface
Parameters:
message - message from sender
Returns:
response from subdomain handler
Throws:
cMsgException

handleSubscribeAndGetRequest

public void handleSubscribeAndGetRequest(java.lang.String subject,
                                         java.lang.String type,
                                         int id)
                                  throws cMsgException
Method to synchronously get a single message from the server for a one-time subscription of a subject and type.

Specified by:
handleSubscribeAndGetRequest in interface cMsgSubdomainInterface
Parameters:
subject - message subject subscribed to
type - message type subscribed to
id - message id refering to these specific subject and type values
Throws:
cMsgException

handleSendAndGetRequest

public void handleSendAndGetRequest(cMsgMessageFull message)
                             throws cMsgException
Method to synchronously get a single message from a receiver by sending out a message to be responded to.

Specified by:
handleSendAndGetRequest in interface cMsgSubdomainInterface
Parameters:
message - message requesting what sort of message to get
Throws:
cMsgException

handleUnSendAndGetRequest

public void handleUnSendAndGetRequest(int id)
                               throws cMsgException
Method to handle remove sendAndGet request sent by domain client (hidden from user).

Specified by:
handleUnSendAndGetRequest in interface cMsgSubdomainInterface
Parameters:
id - message id refering to these specific subject and type values
Throws:
cMsgException

handleUnsubscribeAndGetRequest

public void handleUnsubscribeAndGetRequest(java.lang.String subject,
                                           java.lang.String type,
                                           int id)
                                    throws cMsgException
Method to handle remove subscribeAndGet request sent by domain client (hidden from user).

Specified by:
handleUnsubscribeAndGetRequest in interface cMsgSubdomainInterface
Parameters:
subject - message subject subscribed to
type - message type subscribed to
id - message id refering to these specific subject and type values
Throws:
cMsgException

handleSubscribeRequest

public void handleSubscribeRequest(java.lang.String subject,
                                   java.lang.String type,
                                   int id)
                            throws cMsgException
Method to handle subscribe request sent by domain client.

Specified by:
handleSubscribeRequest in interface cMsgSubdomainInterface
Parameters:
subject - message subject to subscribe to
type - message type to subscribe to
id - message id refering to these specific subject and type values
Throws:
cMsgException

handleUnsubscribeRequest

public void handleUnsubscribeRequest(java.lang.String subject,
                                     java.lang.String type,
                                     int id)
                              throws cMsgException
Method to handle unsubscribe request sent by domain client.

Specified by:
handleUnsubscribeRequest in interface cMsgSubdomainInterface
Parameters:
subject - message subject to subscribe to
type - message type to subscribe to
id - message id refering to these specific subject and type values
Throws:
cMsgException

handleShutdownClientsRequest

public void handleShutdownClientsRequest(java.lang.String client,
                                         boolean includeMe)
                                  throws cMsgException
Method to handle request to shutdown clients sent by domain client.

Specified by:
handleShutdownClientsRequest in interface cMsgSubdomainInterface
Parameters:
client - client(s) to be shutdown
includeMe - if true, this client may be shutdown too
Throws:
cMsgException

handleKeepAlive

public void handleKeepAlive()
                     throws cMsgException
Method to handle keepalive sent by domain client checking to see if the domain server socket is still up.

Specified by:
handleKeepAlive in interface cMsgSubdomainInterface
Throws:
cMsgException

handleClientShutdown

public void handleClientShutdown()
                          throws cMsgException
Method to handle a client or domain server down.

Specified by:
handleClientShutdown in interface cMsgSubdomainInterface
Throws:
cMsgException

hasSend

public boolean hasSend()
Method to tell if the "send" cMsg API function is implemented by this interface implementation in the handleSendRequest(org.jlab.coda.cMsg.cMsgMessageFull) method.

Specified by:
hasSend in interface cMsgSubdomainInterface
Returns:
true if send implemented in handleSendRequest(org.jlab.coda.cMsg.cMsgMessageFull)

hasSyncSend

public boolean hasSyncSend()
Method to tell if the "syncSend" cMsg API function is implemented by this interface implementation in the handleSyncSendRequest(org.jlab.coda.cMsg.cMsgMessageFull) method.

Specified by:
hasSyncSend in interface cMsgSubdomainInterface
Returns:
true if send implemented in handleSyncSendRequest(org.jlab.coda.cMsg.cMsgMessageFull)

hasSubscribeAndGet

public boolean hasSubscribeAndGet()
Method to tell if the "subscribeAndGet" cMsg API function is implemented by this interface implementation in the handleSubscribeAndGetRequest(java.lang.String, java.lang.String, int) method.

Specified by:
hasSubscribeAndGet in interface cMsgSubdomainInterface
Returns:
true if subscribeAndGet implemented in handleSubscribeAndGetRequest(java.lang.String, java.lang.String, int)

hasSendAndGet

public boolean hasSendAndGet()
Method to tell if the "sendAndGet" cMsg API function is implemented by this interface implementation in the handleSendAndGetRequest(org.jlab.coda.cMsg.cMsgMessageFull) method.

Specified by:
hasSendAndGet in interface cMsgSubdomainInterface
Returns:
true if sendAndGet implemented in handleSendAndGetRequest(org.jlab.coda.cMsg.cMsgMessageFull)

hasSubscribe

public boolean hasSubscribe()
Method to tell if the "subscribe" cMsg API function is implemented by this interface implementation in the handleSubscribeRequest(java.lang.String, java.lang.String, int) method.

Specified by:
hasSubscribe in interface cMsgSubdomainInterface
Returns:
true if subscribe implemented in handleSubscribeRequest(java.lang.String, java.lang.String, int)

hasUnsubscribe

public boolean hasUnsubscribe()
Method to tell if the "unsubscribe" cMsg API function is implemented by this interface implementation in the handleUnsubscribeRequest(java.lang.String, java.lang.String, int) method.

Specified by:
hasUnsubscribe in interface cMsgSubdomainInterface
Returns:
true if unsubscribe implemented in handleUnsubscribeRequest(java.lang.String, java.lang.String, int)

hasShutdown

public boolean hasShutdown()
Method to tell if the "shutdown" cMsg API function is implemented by this interface implementation in the handleShutdownClientsRequest(java.lang.String, boolean) method.

Specified by:
hasShutdown in interface cMsgSubdomainInterface
Returns:
true if shutdown implemented in handleShutdownClientsRequest(java.lang.String, boolean)