ObjectInstance objectInstance = mBeanServer.getObjectInstance(destinationObjectName);
CompositeData[] compositeData = (CompositeData[]) mBeanServer.invoke(objectInstance.getObjectName(), "browse", new Object[] { selector }, new String[] { String.class.getName() });
if (compositeData.length > 0) {
JMSMessageInfo[] messageInfos = new JMSMessageInfo[compositeData.length];
for (int i = 0; i < compositeData.length; i++) {
JMSMessageInfo jmsMessageInfo = new JMSMessageInfo();
CompositeData data = compositeData[i];
if (compositeData[0].getCompositeType().getTypeName().equals("org.apache.activemq.command.ActiveMQTextMessage")) {
jmsMessageInfo.setMessage((String) data.get(CompositeDataConstants.MESSAGE_TEXT));
} else {
jmsMessageInfo.setMessage("Only Text Messages will be displayed..");
}
jmsMessageInfo.setPriority((Integer) data.get("JMSPriority"));
jmsMessageInfo.setMessageId((String) data.get("JMSMessageID"));
jmsMessageInfo.setDestination((String) data.get("JMSDestination"));
jmsMessageInfo.setTimeStamp(((Date) data.get("JMSTimestamp")).getTime());
jmsMessageInfo.setExpiration((Long) data.get("JMSExpiration"));
jmsMessageInfo.setJmsType((String) data.get("JMSType"));
jmsMessageInfo.setReplyTo((String) data.get("JMSReplyTo"));
jmsMessageInfo.setCorrelationId((String) data.get("JMSCorrelationID"));
messageInfos[i] = jmsMessageInfo;
}
return messageInfos;
}
return new JMSMessageInfo[0];