Search in sources :

Example 1 with MQAddressList

use of com.sun.enterprise.connectors.jms.system.MQAddressList in project Payara by payara.

the class JMSDestination method getDefaultAddressList.

/*   private boolean isDAS(String targetName) {
             //return true;
            if (isAConfig(targetName)) {
            return false;
            }

            return getServerByName(targetName).isDas();

        }*/
/* private Server getServerByName(String serverName){
            Domain domain = Globals.get(Domain.class);
            Servers servers = domain.getServers();
            List serverList = servers.getServer();

            for (int i=0; i < serverList.size(); i++){
                Server server = (Server) serverList.get(i);
                if(serverName.equals(server.getName()))
                    return server;
            }
            return null;
        }*/
protected MQAddressList getDefaultAddressList(JmsService jmsService) throws Exception {
    MQAddressList list = new MQAddressList(jmsService);
    list.setup(false);
    return list;
}
Also used : MQAddressList(com.sun.enterprise.connectors.jms.system.MQAddressList)

Example 2 with MQAddressList

use of com.sun.enterprise.connectors.jms.system.MQAddressList in project Payara by payara.

the class JMSDestination method _getMQJMXConnectorInfo.

protected MQJMXConnectorInfo _getMQJMXConnectorInfo(String targetName, JmsService jmsService, Class mqRAClassName, ServerContext serverContext, Config config, Domain domain) throws ConnectorRuntimeException {
    try {
        // If DAS, use the default address list, else obtain
        String connectionURL = null;
        MQAddressList mqadList = new MQAddressList();
        if (getTypeForTarget(targetName) == CommandTarget.DAS) {
            connectionURL = getDefaultAddressList(jmsService).toString();
        } else {
            // Standalone server instance
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, "not in DAS");
                logger.log(Level.FINE, " _getMQJMXConnectorInfo - NOT in DAS");
            }
            JmsService serverJmsService = getJmsServiceOfStandaloneServerInstance(targetName, config, domain);
            // MQAddressList mqadList = new MQAddressList(serverJmsService, targetName);
            mqadList.setJmsService(serverJmsService);
            mqadList.setTargetName(targetName);
            mqadList.setup(false);
            connectionURL = mqadList.toString();
        }
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, " _getMQJMXConnectorInfo - connection URL " + connectionURL);
        }
        String adminUserName = null;
        String adminPassword = null;
        JmsHost jmsHost = mqadList.getDefaultJmsHost(jmsService);
        if (jmsHost != null) {
            // && jmsHost.isEnabled()) {
            adminUserName = jmsHost.getAdminUserName();
            adminPassword = JmsRaUtil.getUnAliasedPwd(jmsHost.getAdminPassword());
        } else {
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, " _getMQJMXConnectorInfo, using default jms admin user and password ");
            }
        }
        ResourceAdapter raInstance = getConfiguredRA(mqRAClassName, connectionURL, adminUserName, adminPassword);
        String jmxServiceURL = null, jmxServiceURLList = null;
        Map<String, ?> jmxConnectorEnv = null;
        Method[] methds = raInstance.getClass().getMethods();
        for (int i = 0; i < methds.length; i++) {
            Method m = methds[i];
            if (m.getName().equalsIgnoreCase("get" + JMXSERVICEURLLIST)) {
                jmxServiceURLList = (String) m.invoke(raInstance, new Object[] {});
            } else if (m.getName().equalsIgnoreCase("get" + JMXCONNECTORENV)) {
                jmxConnectorEnv = (Map<String, ?>) m.invoke(raInstance, new Object[] {});
            }
        }
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, " _getMQJMXConnectorInfo - jmxServiceURLList " + jmxServiceURLList);
            logger.log(Level.FINE, " _getMQJMXConnectorInfo - jmxConnectorEnv " + jmxConnectorEnv);
        }
        jmxServiceURL = getFirstJMXServiceURL(jmxServiceURLList);
        MQJMXConnectorInfo mqInfo = new MQJMXConnectorInfo(targetName, ActiveJmsResourceAdapter.getBrokerInstanceName(jmsService), jmsService.getType(), jmxServiceURL, jmxConnectorEnv);
        return mqInfo;
    } catch (Exception e) {
        e.printStackTrace();
        ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
        cre.initCause(e);
        throw cre;
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) MQAddressList(com.sun.enterprise.connectors.jms.system.MQAddressList) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) Method(java.lang.reflect.Method) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ActiveJmsResourceAdapter(com.sun.enterprise.connectors.jms.system.ActiveJmsResourceAdapter) ResourceAdapter(javax.resource.spi.ResourceAdapter) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost)

Example 3 with MQAddressList

use of com.sun.enterprise.connectors.jms.system.MQAddressList in project Payara by payara.

the class JMSDestination method _getMQJMXConnectorInfoForCluster.

/**
 *  Gets the <code>MQJMXConnector</code> object for a cluster. Since this code is
 *  executed in DAS, an admin API is used to resolve hostnames and ports of
 *  cluster instances for LOCAL type brokers while creating the connectionURL.
 */
protected MQJMXConnectorInfo _getMQJMXConnectorInfoForCluster(String target, JmsService jmsService, Class mqRAClassName, ServerContext serverContext) throws ConnectorRuntimeException {
    // Create a new RA instance.
    ResourceAdapter raInstance = null;
    // Set the ConnectionURL
    MQAddressList list = null;
    try {
        if (jmsService.getType().equalsIgnoreCase(ActiveJmsResourceAdapter.REMOTE)) {
            list = getDefaultAddressList(jmsService);
        } else {
            list = new MQAddressList();
            CommandTarget ctarget = this.getTypeForTarget(target);
            if (ctarget == CommandTarget.CLUSTER) {
                Server[] servers = list.getServersInCluster(target);
                if (servers != null && servers.length > 0)
                    list.setInstanceName(servers[0].getName());
            } else if (ctarget == CommandTarget.CLUSTERED_INSTANCE) {
                list.setInstanceName(target);
            }
            java.util.Map<String, JmsHost> hostMap = list.getResolvedLocalJmsHostsInMyCluster(true);
            if (hostMap.size() == 0) {
                String msg = localStrings.getLocalString("mqjmx.no_jms_hosts", "No JMS Hosts Configured");
                throw new ConnectorRuntimeException(msg);
            }
            for (JmsHost host : hostMap.values()) {
                list.addMQUrl(host);
            }
        }
        String connectionUrl = list.toString();
        String adminUserName = null;
        String adminPassword = null;
        JmsHost jmsHost = list.getDefaultJmsHost(jmsService);
        if (jmsHost != null) {
            // && jmsHost.isEnabled()) {
            adminUserName = jmsHost.getAdminUserName();
            adminPassword = JmsRaUtil.getUnAliasedPwd(jmsHost.getAdminPassword());
        } else {
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, " _getMQJMXConnectorInfo, using default jms admin user and password ");
            }
        }
        raInstance = getConfiguredRA(mqRAClassName, connectionUrl, adminUserName, adminPassword);
    } catch (Exception e) {
        e.printStackTrace();
        ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
        cre.initCause(e);
        throw cre;
    }
    try {
        String jmxServiceURL = null, jmxServiceURLList = null;
        Map<String, ?> jmxConnectorEnv = null;
        Method[] methds = raInstance.getClass().getMethods();
        for (int i = 0; i < methds.length; i++) {
            Method m = methds[i];
            if (m.getName().equalsIgnoreCase("get" + JMXSERVICEURLLIST)) {
                jmxServiceURLList = (String) m.invoke(raInstance, new Object[] {});
                if (jmxServiceURLList != null && !jmxServiceURLList.trim().equals("")) {
                    jmxServiceURL = getFirstJMXServiceURL(jmxServiceURLList);
                }
            } else if (m.getName().equalsIgnoreCase("get" + JMXCONNECTORENV)) {
                jmxConnectorEnv = (Map<String, ?>) m.invoke(raInstance, new Object[] {});
            }
        }
        MQJMXConnectorInfo mqInfo = new MQJMXConnectorInfo(target, ActiveJmsResourceAdapter.getBrokerInstanceName(jmsService), jmsService.getType(), jmxServiceURL, jmxConnectorEnv);
        return mqInfo;
    } catch (Exception e) {
        e.printStackTrace();
        ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
        cre.initCause(e);
        throw cre;
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) MQAddressList(com.sun.enterprise.connectors.jms.system.MQAddressList) CommandTarget(org.glassfish.config.support.CommandTarget) Method(java.lang.reflect.Method) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) java.util(java.util) ActiveJmsResourceAdapter(com.sun.enterprise.connectors.jms.system.ActiveJmsResourceAdapter) ResourceAdapter(javax.resource.spi.ResourceAdapter) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost)

Aggregations

MQAddressList (com.sun.enterprise.connectors.jms.system.MQAddressList)3 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)2 JmsHost (com.sun.enterprise.connectors.jms.config.JmsHost)2 ActiveJmsResourceAdapter (com.sun.enterprise.connectors.jms.system.ActiveJmsResourceAdapter)2 Method (java.lang.reflect.Method)2 ResourceAdapter (javax.resource.spi.ResourceAdapter)2 JmsService (com.sun.enterprise.connectors.jms.config.JmsService)1 java.util (java.util)1 CommandTarget (org.glassfish.config.support.CommandTarget)1