public class cMsgDomainAdapter extends java.lang.Object implements cMsgDomainInterface
Modifier and Type | Field and Description |
---|---|
protected boolean |
connected
Boolean indicating whether this client is connected to the domain or not.
|
protected int |
debug
Level of debug output for this class.
|
protected java.lang.String |
description
Description of the client.
|
protected java.lang.String |
domain
Domain being connected to.
|
protected java.lang.String |
host
Host the client is running on.
|
protected java.lang.String |
name
Name of this client.
|
protected boolean |
receiving
Boolean indicating whether this client's callbacks are active or not.
|
protected cMsgShutdownHandlerInterface |
shutdownHandler
Handler for client shutdown command sent by server.
|
protected java.lang.String |
UDL
The Uniform Domain Locator which tells the location of a domain.
|
protected java.lang.String |
UDLremainder
String containing the remainder part of the UDL.
|
Constructor and Description |
---|
cMsgDomainAdapter()
Constructor which gives a default shutdown handler to this client.
|
Modifier and Type | Method and Description |
---|---|
void |
connect()
Method to connect to a particular domain.
|
void |
disconnect()
Method to close the connection to the domain.
|
void |
flush(int timeout)
Method to force cMsg client to send pending communications with domain.
|
java.lang.String |
getCurrentUDL()
Get the UDL the client is currently connected to.
|
int |
getDebug()
Get client's level of debug output.
|
java.lang.String |
getDescription()
Get the client's description.
|
java.lang.String |
getDomain()
Get the name of the domain connected to.
|
java.lang.String |
getHost()
Get the host the client is running on.
|
java.lang.String |
getInfo(java.lang.String s)
General purpose I/O method which gets a string that the implementation
class wants to return up to the top (this) level API.
|
java.lang.String |
getName()
Get the name of the client.
|
java.lang.String |
getServerHost()
Get the host of the server (if any) that this client is connected to.
|
int |
getServerPort()
Get the port of the server (if any) that this client is connected to.
|
cMsgShutdownHandlerInterface |
getShutdownHandler()
Method to get the shutdown handler of the client.
|
java.lang.String |
getUDL()
Get the client's UDL.
|
java.lang.String |
getUDLRemainder()
Get the client's UDL remainder.
|
boolean |
isConnected()
Method to determine if this object is still connected to the domain or not.
|
boolean |
isReceiving()
Method telling whether callbacks are activated or not.
|
cMsgMessage |
monitor(java.lang.String command)
This method is a synchronous call to receive a message containing monitoring data
which describes the state of the cMsg domain the user is connected to.
|
void |
send(cMsgMessage message)
Method to send a message to the domain for further distribution.
|
cMsgMessage |
sendAndGet(cMsgMessage message,
int timeout)
The message is sent as it would be in the
cMsgDomainInterface.send(org.jlab.coda.cMsg.cMsgMessage) method and a single synchronous
response is received. |
void |
setDebug(int debug)
Set client's level of debug output.
|
void |
setDescription(java.lang.String description)
Set the description of the client.
|
void |
setName(java.lang.String name)
Set the name of the client.
|
void |
setShutdownHandler(cMsgShutdownHandlerInterface handler)
Method to set the shutdown handler of the client.
|
void |
setUDL(java.lang.String UDL)
Set the UDL of the client.
|
void |
setUDLRemainder(java.lang.String UDLremainder)
Set the UDL remainder of the client.
|
void |
shutdownClients(java.lang.String client,
boolean includeMe)
Method to shutdown the given client(s).
|
void |
shutdownServers(java.lang.String server,
boolean includeMyServer)
Method to shutdown the given server(s).
|
void |
start()
Method to start or activate the subscription callbacks.
|
void |
stop()
Method to stop or deactivate the subscription callbacks.
|
cMsgSubscriptionHandle |
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.
|
cMsgMessage |
subscribeAndGet(java.lang.String subject,
java.lang.String type,
int timeout)
This method is like a one-time subscribe.
|
int |
syncSend(cMsgMessage message,
int timeout)
Method to send a message to the domain for further distribution
and wait for a response from the subdomain handler that got it.
|
void |
unsubscribe(cMsgSubscriptionHandle handle)
Method to unsubscribe a previous subscription to receive messages of a subject and type
from the domain.
|
protected volatile boolean connected
protected volatile boolean receiving
protected java.lang.String UDL
protected java.lang.String UDLremainder
protected java.lang.String domain
protected java.lang.String name
protected java.lang.String description
protected java.lang.String host
protected cMsgShutdownHandlerInterface shutdownHandler
protected int debug
public cMsgDomainAdapter()
public boolean isConnected()
isConnected
in interface cMsgDomainInterface
public void connect() throws cMsgException
connect
in interface cMsgDomainInterface
cMsgException
- always throws an exception since this is a dummy implementationpublic void disconnect() throws cMsgException
disconnect
in interface cMsgDomainInterface
cMsgException
- always throws an exception since this is a dummy implementationpublic void send(cMsgMessage message) throws cMsgException
send
in interface cMsgDomainInterface
message
- message to sendcMsgException
- always throws an exception since this is a dummy implementationpublic int syncSend(cMsgMessage message, int timeout) throws cMsgException
syncSend
in interface cMsgDomainInterface
message
- message to sendtimeout
- time in milliseconds to wait for a responsecMsgException
- always throws an exception since this is a dummy implementationpublic void flush(int timeout) throws cMsgException
flush
in interface cMsgDomainInterface
timeout
- time in milliseconds to wait for completioncMsgException
- always throws an exception since this is a dummy implementationpublic cMsgMessage subscribeAndGet(java.lang.String subject, java.lang.String type, int timeout) throws cMsgException, java.util.concurrent.TimeoutException
subscribeAndGet
in interface cMsgDomainInterface
subject
- subject of message desired from servertype
- type of message desired from servertimeout
- time in milliseconds to wait for a messagecMsgException
- always throws an exception since this is a dummy implementationjava.util.concurrent.TimeoutException
- if timeout occurspublic cMsgMessage sendAndGet(cMsgMessage message, int timeout) throws cMsgException, java.util.concurrent.TimeoutException
cMsgDomainInterface.send(org.jlab.coda.cMsg.cMsgMessage)
method and a single synchronous
response is received. The domain 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.
The response may be null.sendAndGet
in interface cMsgDomainInterface
message
- message sent to servertimeout
- time in milliseconds to wait for a response message, zero means wait forever.cMsgException
- always throws an exception since this is a dummy implementationjava.util.concurrent.TimeoutException
- if timeout occurspublic cMsgSubscriptionHandle subscribe(java.lang.String subject, java.lang.String type, cMsgCallbackInterface cb, java.lang.Object userObj) throws cMsgException
subscribe
in interface cMsgDomainInterface
subject
- message subjecttype
- message typecb
- callback object whose single method is called upon receiving a message
of subject and typeuserObj
- any user-supplied object to be given to the callback method as an argumentcMsgException
- always throws an exception since this is a dummy implementationpublic void unsubscribe(cMsgSubscriptionHandle handle) throws cMsgException
unsubscribe
in interface cMsgDomainInterface
handle
- the object returned from a subscribe callcMsgException
- always throws an exception since this is a dummy implementationpublic cMsgMessage monitor(java.lang.String command) throws cMsgException
monitor
in interface cMsgDomainInterface
command
- directive for monitoring processcMsgException
- always throws an exception since this is a dummy implementationpublic void start()
start
in interface cMsgDomainInterface
public void stop()
stop
in interface cMsgDomainInterface
public void shutdownClients(java.lang.String client, boolean includeMe) throws cMsgException
shutdownClients
in interface cMsgDomainInterface
client
- client(s) to be shutdownincludeMe
- if true, it is permissible to shutdown calling clientcMsgException
- always throws an exception since this is a dummy implementationpublic void shutdownServers(java.lang.String server, boolean includeMyServer) throws cMsgException
shutdownServers
in interface cMsgDomainInterface
server
- server(s) to be shutdownincludeMyServer
- if true, it is permissible to shutdown calling client's
cMsg servercMsgException
- always throws an exception since this is a dummy implementationpublic void setShutdownHandler(cMsgShutdownHandlerInterface handler)
setShutdownHandler
in interface cMsgDomainInterface
handler
- shutdown handlerpublic cMsgShutdownHandlerInterface getShutdownHandler()
getShutdownHandler
in interface cMsgDomainInterface
public java.lang.String getDomain()
getDomain
in interface cMsgDomainInterface
public java.lang.String getName()
getName
in interface cMsgDomainInterface
public void setName(java.lang.String name)
setName
in interface cMsgDomainInterface
name
- name of clientpublic java.lang.String getDescription()
getDescription
in interface cMsgDomainInterface
public void setDescription(java.lang.String description)
setDescription
in interface cMsgDomainInterface
description
- description of clientpublic java.lang.String getUDLRemainder()
getUDLRemainder
in interface cMsgDomainInterface
public void setUDLRemainder(java.lang.String UDLremainder)
setUDLRemainder
in interface cMsgDomainInterface
UDLremainder
- UDL remainder of client UDLpublic java.lang.String getUDL()
getUDL
in interface cMsgDomainInterface
public void setUDL(java.lang.String UDL) throws cMsgException
setUDL
in interface cMsgDomainInterface
UDL
- UDL of clientcMsgException
- never in this adapterpublic java.lang.String getCurrentUDL()
getCurrentUDL
in interface cMsgDomainInterface
public java.lang.String getHost()
getHost
in interface cMsgDomainInterface
public java.lang.String getServerHost()
getServerHost
in interface cMsgDomainInterface
public int getServerPort()
getServerPort
in interface cMsgDomainInterface
public java.lang.String getInfo(java.lang.String s)
getInfo
in interface cMsgDomainInterface
s
- input stringpublic boolean isReceiving()
isReceiving
in interface cMsgDomainInterface
public void setDebug(int debug)
setDebug
in interface cMsgDomainInterface
debug
- client's level of debug outputpublic int getDebug()
getDebug
in interface cMsgDomainInterface