MQAdministratorpublic class MQAdministrator extends Object Represents MQAdministrator of the default-jms-host of the
target. |
Fields Summary |
---|
static Logger | logger | private static com.sun.enterprise.util.i18n.StringManager | localStrings | private String | target |
Constructors Summary |
---|
public MQAdministrator()Creates JMSAdmin object for the curremt Instance.
| public MQAdministrator(String target)Creates JMSAdmin object from the name of the target passed in.
this.target = target;
|
Methods Summary |
---|
public void | createPhysicalDestination(java.lang.String destName, boolean isQueue)
MQJMXConnectorInfo mqInfo = null;
try {
if (this.target == null) {
this.target = getClusterName();
}
if (destinationExists(destName, isQueue)) {
logger.log(Level.INFO, "Destination " + destName + "exists in broker");
return;
}
mqInfo = MQJMXConnectorHelper.getMQJMXConnectorInfo(target) [0];
MBeanServerConnection mbsc = mqInfo.getMQMBeanServerConnection();
ObjectName on = new ObjectName(
MQObjectName.DESTINATION_MANAGER_CONFIG_MBEAN_NAME);
String [] signature = null;
AttributeList destAttrs = null;
Object [] params = null;
String destType = DestinationType.TOPIC;
destAttrs = new AttributeList();
if (isQueue) {
destAttrs.add(new Attribute(IASJmsUtil.getMaxActiveConsumersAttribute(),
new Integer(IASJmsUtil.getDefaultMaxActiveConsumers())));
destType = DestinationType.QUEUE;
}
/*
if (mqInfo.getBrokerType().equalsIgnoreCase(ActiveJmsResourceAdapter.LOCAL)) {
destAttrs.add( new Attribute ("LocalDeliveryPreferred",
new Boolean("true")));
}
*/
if ((destAttrs == null) || (destAttrs.size() == 0)){
signature = new String [] {
"java.lang.String",
"java.lang.String"};
params = new Object [] {destType, destName};
} else {
signature = new String [] {
"java.lang.String",
"java.lang.String",
"javax.management.AttributeList"};
params = new Object [] {destType, destName, destAttrs};
}
mbsc.invoke(on, "create", params, signature);
} catch (Exception e) {
handleException(e);
} finally {
try {
if(mqInfo != null) {
mqInfo.closeMQMBeanServerConnection();
}
} catch (Exception e) {
handleException(e);
}
}
| public boolean | destinationExists(java.lang.String destName, boolean isQueue)
MQJMXConnectorInfo mqInfo = null;
try {
mqInfo = MQJMXConnectorHelper.getMQJMXConnectorInfo(target) [0];
MBeanServerConnection mbsc = mqInfo.getMQMBeanServerConnection();
ObjectName objName
= new ObjectName(
MQObjectName.DESTINATION_MANAGER_MONITOR_MBEAN_NAME);
ObjectName destinationObjNames[] =
(ObjectName[])mbsc.invoke(objName,
DestinationOperations.GET_DESTINATIONS, null, null);
String destType = DestinationType.TOPIC;
if (isQueue) {
destType = DestinationType.QUEUE;
}
for (int i = 0; i < destinationObjNames.length; ++i) {
ObjectName oneDestObjName = destinationObjNames[i];
String oneDestName = (String)mbsc.getAttribute(oneDestObjName,
DestinationAttributes.NAME);
String oneDestType = (String)mbsc.getAttribute(oneDestObjName,
DestinationAttributes.TYPE);
if (oneDestName.equals(destName.trim())
&& oneDestType.equals(destType)) {
return true;
}
}
}catch (Exception e) {
logger.log(Level.WARNING, "Exception occurred when trying to check "
+ "if destination exists");
}
return false;
| private java.lang.String | getClusterName()
return ClusterHelper.getClusterForInstance(
ApplicationServer.getServerContext().getConfigContext(),
ApplicationServer.getServerContext().getInstanceName()).getName();
| private com.sun.enterprise.connectors.ConnectorRuntimeException | handleException(java.lang.Exception e)
logger.log(Level.WARNING,""+e.getMessage(), e);
ConnectorRuntimeException cre =
new ConnectorRuntimeException(e.getMessage());
cre.initCause(e);
return cre;
|
|