if ( DEBUG ) {
logger.log(Logger.DEBUG, this.getClass().getName() + ": " +
"GetConnections: " + cmd_props);
}
ConnectionManager cm = Globals.getConnectionManager();
String serviceName = (String)cmd_props.get(MessageType.JMQ_SERVICE_NAME);
Long cxnId = (Long)cmd_props.get(MessageType.JMQ_CONNECTION_ID);
int status = Status.OK;
String errMsg = null;
Vector v = new Vector();
Service s = null;
/*
* Only one of {JMQServiceName,JMQConnectionID} will be set.
*
* If JMQServiceName is set, send back only connections on the
* specified service. If JMQServiceName is not set, send back connections
* on all services.
*
* If JMQConnectionID is set, send back only the specified connection;
* send back an error if the id specified cannot be found.
*
* Scenarios:
* JMQServiceName unset, JMQConnectionID unset
* -> send back all connections
* JMQServiceName=jms, JMQConnectionID unset
* -> send back all connections on service 'jms'
* JMQServiceName unset, JMQConnectionID=1234
* -> send back connection with ID=1234
*
* This won't happen but in case it comes across we can do:
* JMQServiceName=jms, JMQConnectionID=1234
* -> send back connection with ID=1234 on service 'jms'
*/
if (serviceName != null) {
s = Globals.getServiceManager().getService(serviceName);
if (s == null) {
status = Status.NOT_FOUND;
errMsg = rb.getString(rb.X_NO_SUCH_SERVICE, serviceName);
}
}
if (status == Status.OK) {
ConnectionInfo cxnInfo = null;
IMQConnection cxn = null;
if (cxnId != null) {
// Get info for one connection
cxn = (IMQConnection)cm.getConnection(
new ConnectionUID(cxnId.longValue()));
if (cxn != null) {
if (DEBUG) {
cxn.dump();
}
cxnInfo = cxn.getConnectionInfo();
v.add(getConnectionInfoHashtable(cxnInfo));
} else {
status = Status.NOT_FOUND;
errMsg = rb.getString(rb.E_NO_SUCH_CONNECTION,
String.valueOf(cxnId.longValue()));
}
} else {
// Get info for all connections on a service
List connections = cm.getConnectionList(s);
Iterator itr = connections.iterator();
while (itr.hasNext()) {
cxn = (IMQConnection)itr.next();
cxnInfo = cxn.getConnectionInfo();
v.add(getConnectionInfoHashtable(cxnInfo));