org.jlab.coda.cMsg.subdomains
Class Database

java.lang.Object
  extended by org.jlab.coda.cMsg.cMsgSubdomainAdapter
      extended by org.jlab.coda.cMsg.subdomains.Database
All Implemented Interfaces:
cMsgSubdomainInterface

public class Database
extends cMsgSubdomainAdapter

cMsg subdomain handler for database subdomain. Executes sql statement from msg payload. Gets database parameters from UDL. UDL: cMsg:cMsg://host:port/Database?driver=myDriver&url=myURL&account=myAccount&password=myPassword

Version:
1.0
Author:
Elliott Wolin

Constructor Summary
Database()
           
 
Method Summary
 void handleClientShutdown()
          Method to handle a client shutdown.
 void handleSendRequest(cMsgMessageFull msg)
          Executes sql insert or update statement from message payload.
 int handleSyncSendRequest(cMsgMessageFull msg)
          Method to handle message sent by domain client in synchronous mode.
 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 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.
 void registerClient(cMsgClientInfo info)
          Method to register domain 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 org.jlab.coda.cMsg.cMsgSubdomainAdapter
handleKeepAlive, handleSendAndGetRequest, handleShutdownClientsRequest, handleSubscribeAndGetRequest, handleSubscribeRequest, handleUnSendAndGetRequest, handleUnsubscribeAndGetRequest, handleUnsubscribeRequest, hasSendAndGet, hasShutdown, hasSubscribe, hasSubscribeAndGet, hasUnsubscribe, setMessageDeliverer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Database

public Database()
Method Detail

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
Overrides:
hasSend in class cMsgSubdomainAdapter
Returns:
true if get 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
Overrides:
hasSyncSend in class cMsgSubdomainAdapter
Returns:
true if send implemented in handleSyncSendRequest(org.jlab.coda.cMsg.cMsgMessageFull)

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
Overrides:
setUDLRemainder in class cMsgSubdomainAdapter
Parameters:
UDLRemainder - last part of the UDL appropriate to the subdomain handler
Throws:
cMsgException

registerClient

public void registerClient(cMsgClientInfo info)
                    throws cMsgException
Method to register domain client. Creates separate database connection for each client connection. UDL contains driver name, database JDBC URL, account, and password Column names are fixed (domain, sender, subject, etc.).

Specified by:
registerClient in interface cMsgSubdomainInterface
Overrides:
registerClient in class cMsgSubdomainAdapter
Parameters:
info - information about client
Throws:
cMsgException - upon error

handleSendRequest

public void handleSendRequest(cMsgMessageFull msg)
                       throws cMsgException
Executes sql insert or update statement from message payload.

Specified by:
handleSendRequest in interface cMsgSubdomainInterface
Overrides:
handleSendRequest in class cMsgSubdomainAdapter
Parameters:
msg - message from sender.
Throws:
cMsgException

handleSyncSendRequest

public int handleSyncSendRequest(cMsgMessageFull msg)
                          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
Overrides:
handleSyncSendRequest in class cMsgSubdomainAdapter
Parameters:
msg - message from sender
Returns:
response from subdomain handler
Throws:
cMsgException

handleClientShutdown

public void handleClientShutdown()
                          throws cMsgException
Method to handle a client shutdown.

Specified by:
handleClientShutdown in interface cMsgSubdomainInterface
Overrides:
handleClientShutdown in class cMsgSubdomainAdapter
Throws:
cMsgException