FileDocCategorySizeDatePackage
MQAdministrator.javaAPI DocGlassfish v2 API7780Fri May 04 22:34:26 BST 2007com.sun.enterprise.connectors.system

MQAdministrator

public class MQAdministrator extends Object
Represents MQAdministrator of the default-jms-host of the target.
author
Binod P.G

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.

param
target Name of the target. Eg: cluster1 or server1

        this.target = target;
    
Methods Summary
public voidcreatePhysicalDestination(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 booleandestinationExists(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.StringgetClusterName()

        return ClusterHelper.getClusterForInstance(
                        ApplicationServer.getServerContext().getConfigContext(),
                        ApplicationServer.getServerContext().getInstanceName()).getName();
    
private com.sun.enterprise.connectors.ConnectorRuntimeExceptionhandleException(java.lang.Exception e)

        logger.log(Level.WARNING,""+e.getMessage(), e);
        ConnectorRuntimeException cre = 
             new ConnectorRuntimeException(e.getMessage());
        cre.initCause(e);
        return cre;