use of com.sun.messaging.jmq.util.admin.ConnectionInfo in project openmq by eclipse-ee4j.
the class ServiceUtil method getConsumerIDs.
public static List getConsumerIDs(String service) {
List consumerIDs = new ArrayList(), connections = ConnectionUtil.getConnectionInfoList(service);
if ((connections == null) || (connections.size() == 0)) {
return (consumerIDs);
}
Iterator itr = connections.iterator();
while (itr.hasNext()) {
ConnectionInfo cxnInfo = (ConnectionInfo) itr.next();
long cxnID = cxnInfo.uuid;
List oneCxnConsumerIDs = ConnectionUtil.getConsumerIDs(cxnID);
consumerIDs.addAll(oneCxnConsumerIDs);
}
return (consumerIDs);
}
use of com.sun.messaging.jmq.util.admin.ConnectionInfo in project openmq by eclipse-ee4j.
the class IMQConnection method getConnectionInfo.
public ConnectionInfo getConnectionInfo() {
if (coninfo == null) {
coninfo = new ConnectionInfo();
coninfo.id = (conId == null ? empty : conId.toString().getBytes());
coninfo.remoteIP = remoteIP;
coninfo.service = service.getName();
}
coninfo.user = null;
Principal principal = null;
try {
if ((principal = getAuthenticatedName()) != null) {
coninfo.user = principal.getName();
}
} catch (BrokerException e) {
logger.log(Logger.DEBUG, "Exception getting authentication name " + conId);
coninfo.user = e.getMessage();
}
coninfo.uuid = this.conId.longValue();
coninfo.metrics = (MetricCounters) counters.clone();
coninfo.clientID = (String) getClientData(CLIENT_ID);
coninfo.nproducers = producers.size();
if ((coninfo.userAgent = (String) getClientData(USER_AGENT)) == null) {
coninfo.userAgent = "";
}
int cnt = 0;
synchronized (sessions) {
Iterator itr = sessions.values().iterator();
while (itr.hasNext()) {
cnt += ((Session) itr.next()).getConsumerCnt();
}
}
coninfo.nconsumers = cnt;
return coninfo;
}
use of com.sun.messaging.jmq.util.admin.ConnectionInfo in project openmq by eclipse-ee4j.
the class ConnectionUtil method getConnectionInfoList.
/**
* Returns a List of ConnectionInfo for the given service or all services if the passed service is null.
*/
public static List getConnectionInfoList(String service) {
ConnectionManager cm = Globals.getConnectionManager();
List connections, connectionInfoList = new ArrayList();
IMQConnection cxn;
ConnectionInfo cxnInfo;
try {
Service s = null;
if (service != null) {
s = Globals.getServiceManager().getService(service);
/*
* If service object is null, service may not exist or is inactive
*/
if (s == null) {
return (connectionInfoList);
}
}
connections = cm.getConnectionList(s);
} catch (Exception e) {
BrokerResources rb = Globals.getBrokerResources();
Logger logger = Globals.getLogger();
logger.log(Logger.WARNING, rb.getString(rb.W_JMX_FAILED_TO_OBTAIN_CONNECTION_LIST), e);
return (connectionInfoList);
}
if (connections.size() == 0) {
return (connectionInfoList);
}
Iterator iter = connections.iterator();
while (iter.hasNext()) {
cxn = (IMQConnection) iter.next();
cxnInfo = cxn.getConnectionInfo();
connectionInfoList.add(cxnInfo);
}
return (connectionInfoList);
}
use of com.sun.messaging.jmq.util.admin.ConnectionInfo in project openmq by eclipse-ee4j.
the class ConnectionUtil method getConnectionInfo.
/**
* Returns the ConnectionInfo for the passed connection ID.
*/
public static ConnectionInfo getConnectionInfo(long id) {
ConnectionManager cm = Globals.getConnectionManager();
ConnectionInfo cxnInfo = null;
IMQConnection cxn = null;
cxn = (IMQConnection) cm.getConnection(new ConnectionUID(id));
if (cxn == null) {
return (null);
}
cxnInfo = cxn.getConnectionInfo();
return (cxnInfo);
}
use of com.sun.messaging.jmq.util.admin.ConnectionInfo in project openmq by eclipse-ee4j.
the class ConsumerUtil method getUser.
private static String getUser(ConsumerUID cid) {
ConnectionUID cxnId = getConnectionUID(cid);
if (cxnId == null) {
return (null);
}
ConnectionInfo cxnInfo = ConnectionUtil.getConnectionInfo(cxnId.longValue());
if (cxnInfo == null) {
return (null);
}
return (cxnInfo.user);
}
Aggregations