Search in sources :

Example 6 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class ActiveJmsResourceAdapter method setAvailabilityProperties.

/*

     * Set Availability related properties
     * If JMS availability true set availability properties
     * read configured pool information and set.
     */
private void setAvailabilityProperties() throws ConnectorRuntimeException {
    if (!isClustered())
        return;
    try {
        Domain domain = Globals.get(Domain.class);
        ServerContext serverContext = Globals.get(ServerContext.class);
        Server server = domain.getServerNamed(serverContext.getInstanceName());
        JmsService jmsService = server.getConfig().getExtensionByType(JmsService.class);
        if (jmsService.getType().equals(REMOTE)) {
            // been configured with the right properties.
            return;
        }
        AvailabilityService as = server.getConfig().getAvailabilityService();
        if (as == null) {
            if (_logger.isLoggable(Level.FINE))
                logFine("Availability Service is null. Not setting AvailabilityProperties.");
            return;
        }
        boolean useMasterBroker = true;
        if (as.getExtensionByType(JmsAvailability.class) != null && !MASTERBROKER.equalsIgnoreCase(as.getExtensionByType(JmsAvailability.class).getConfigStoreType()))
            useMasterBroker = false;
        // jmsService.getUseMasterBroker() != null ? Boolean.valueOf(jmsService.getUseMasterBroker()) :true;
        boolean isJmsAvailabilityEnabled = this.isJMSAvailabilityOn(as);
        if (_logger.isLoggable(Level.FINE))
            logFine("Setting AvailabilityProperties .. ");
        if (!useMasterBroker || isJmsAvailabilityEnabled) {
            // For conventional cluster of peer brokers and Enhanced Broker Cluster.
            ConnectorDescriptor cd = getDescriptor();
            String clusterName = getMQClusterName();
            ConnectorConfigProperty envProp1 = new ConnectorConfigProperty(CLUSTERID, clusterName, "Cluster Id", "java.lang.String");
            setProperty(cd, envProp1);
            if (brokerInstanceName == null) {
                brokerInstanceName = getBrokerInstanceName(jmsService);
            }
            ConnectorConfigProperty envProp2 = new ConnectorConfigProperty(BROKERID, brokerInstanceName, "Broker Id", "java.lang.String");
            setProperty(cd, envProp2);
            // Only if JMS availability is true - Enhanced Broker Cluster only.
            if (isJmsAvailabilityEnabled) {
                // Set HARequired as true - irrespective of whether it is REMOTE or
                // LOCAL
                ConnectorConfigProperty envProp3 = new ConnectorConfigProperty(HAREQUIRED, "true", "HA Required", "java.lang.String");
                setProperty(cd, envProp3);
                /* The broker has a property to control whether
               * it starts in HA mode or not and that's represented on
               * the RA by BrokerEnableHA.
               * On the MQ Client connection side it is HARequired -
               * this does not control the broker, it just is a client
               * side requirement.
               * So for AS EE, if BrokerType is LOCAL or EMBEDDED,
               * and AS HA is enabled for JMS then both these must be
               * set to true. */
                ConnectorConfigProperty envProp4 = new ConnectorConfigProperty(BROKERENABLEHA, "true", "BrokerEnableHA flag", "java.lang.Boolean");
                setProperty(cd, envProp4);
                String nodeHostName = domain.getNodeNamed(server.getNodeRef()).getNodeHost();
                if (nodeHostName != null) {
                    ConnectorConfigProperty envProp5 = new ConnectorConfigProperty(BROKERBINDADDRESS, nodeHostName, "Broker Bind Address", "java.lang.String");
                    setProperty(cd, envProp5);
                }
                loadDBProperties(as.getExtensionByType(JmsAvailability.class), ClusterMode.ENHANCED);
            } else {
                // Conventional cluster of peer brokers
                JmsAvailability jmsAvailability = as.getExtensionByType(JmsAvailability.class);
                if ("jdbc".equals(jmsAvailability.getMessageStoreType()))
                    loadDBProperties(jmsAvailability, ClusterMode.ENHANCED);
                loadDBProperties(jmsAvailability, ClusterMode.CONVENTIONAL_OF_PEER_BROKERS);
            }
        /*
            ConnectorConfigProperty  envProp4 = new ConnectorConfigProperty  (
                            DBTYPE , DBTYPE_HADB,"DBType",
                            "java.lang.String");
            setProperty(cd, envProp4);



            * The broker has a property to control whether
            * it starts in HA mode or not and that's represented on
            * the RA by BrokerEnableHA.
            * On the MQ Client connection side it is HARequired -
            * this does not control the broker, it just is a client
            * side requirement.
            * So for AS EE, if BrokerType is LOCAL or EMBEDDED,
            * and AS HA is enabled for JMS then both these must be
            * set to true.

            ConnectorConfigProperty  envProp5 = new ConnectorConfigProperty  (
                        BROKERENABLEHA , "true",
                        "BrokerEnableHA flag","java.lang.Boolean");
            setProperty(cd, envProp5);

            String nodeHostName = domain.getNodeNamed(server.getNode()).getNodeHost();
            if (nodeHostName != null)  {
              ConnectorConfigProperty  envProp6 = new ConnectorConfigProperty  (
                          BROKERBINDADDRESS , nodeHostName,
                          "Broker Bind Address","java.lang.String");
              setProperty(cd, envProp6);
            }
            //get pool name
            String poolJNDIName = as.getJmsAvailability().getMqStorePoolName();
            //If no MQ store pool name is specified, use default poolname
            //XXX: default pool name is jdbc/hastore but asadmin
            //configure-ha-cluster creates a resource called
            //"jdbc/<asclustername>-hastore" which needs to be used.
            if (poolJNDIName == null || poolJNDIName =="" ) {
              //get Web container's HA store's pool name
              poolJNDIName = as.getWebContainerAvailability().
                                getHttpSessionStorePoolName();
              logFine("HTTP Session store pool jndi name " +
                         "is " + poolJNDIName);
            }
            //XXX: request HADB team mq-store-pool name to be
            //populated as part of configure-ha-cluster

            JdbcConnectionPool jdbcConPool = getJDBCConnectionPoolInfo(
                                                poolJNDIName);
            //DBProps: compute values from pool object
            String userName = getPropertyFromPool(jdbcConPool, DUSERNAME);
            logFine("HA username is " + userName);

            String password = getPropertyFromPool(jdbcConPool, DPASSWORD);
            logFine("HA Password is " + password);

            String driverClass = jdbcConPool.getDatasourceClassname();
            logFine("HA driverclass" + driverClass);

            dbProps = new Properties();
            dbProps.setProperty(DB_HADB_USER, userName);
            dbProps.setProperty(DB_HADB_PASSWORD, password);
            dbProps.setProperty(DB_HADB_DRIVERCLASS, driverClass);

            //DSProps: compute values from pool object
            String serverList = getPropertyFromPool(jdbcConPool, DSERVERLIST);
            logFine("HADB server list is " + serverList);
            dsProps = new Properties();

            if (serverList != null) {
                dsProps.setProperty(DS_HADB_SERVERLIST, serverList);
            } else {
                _logger.warning("ajra.incorrect_hadb_server_list");
            }

            //set all other properties in dsProps as well.
            Properties p = getDSPropertiesFromThePool(jdbcConPool);
            Iterator iterator = p.keySet().iterator();
            while (iterator.hasNext()) {
                String key = (String) iterator.next();
                String val = (String)p.get(key);
                dsProps.setProperty(key, val);
            }*/
        } else {
            // Conventional cluster with master broker.
            if ("jdbc".equals(as.getExtensionByType(JmsAvailability.class).getMessageStoreType()))
                loadDBProperties(as.getExtensionByType(JmsAvailability.class), ClusterMode.CONVENTIONAL_WITH_MASTER_BROKER);
        }
    } catch (Exception e) {
        ConnectorRuntimeException crex = new ConnectorRuntimeException(e.getMessage());
        throw (ConnectorRuntimeException) crex.initCause(e);
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) AvailabilityService(com.sun.enterprise.config.serverbeans.AvailabilityService) ServerContext(org.glassfish.internal.api.ServerContext) Server(com.sun.enterprise.config.serverbeans.Server) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) JmsAvailability(com.sun.enterprise.connectors.jms.config.JmsAvailability) Domain(com.sun.enterprise.config.serverbeans.Domain) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) MultiException(org.glassfish.hk2.api.MultiException) PrivilegedActionException(java.security.PrivilegedActionException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 7 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class JMSConfigListener method changed.

/**
 * Implementation of org.jvnet.hk2.config.ConfigListener
 */
public UnprocessedChangeEvents changed(PropertyChangeEvent[] events) {
    // Events that we can't process now because they require server restart.
    jmsService = serverConfig.getExtensionByType(JmsService.class);
    List<UnprocessedChangeEvent> unprocessedEvents = new ArrayList<UnprocessedChangeEvent>();
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "In JMSConfigListener - received config event");
    }
    Domain domain = Globals.get(Domain.class);
    String jmsProviderPort = null;
    ServerContext serverContext = Globals.get(ServerContext.class);
    Server thisServer = domain.getServerNamed(serverContext.getInstanceName());
    // if(thisServer.isDas() || thisServer.getCluster() == null)
    {
    // _logger.log(Level.FINE,"JMSConfigListerner server is either das or a stand-alone instance - hence ignoring");
    // return null;
    }
    for (int i = 0; i < events.length; i++) {
        // for (PropertyChangeEvent event : events) {
        PropertyChangeEvent event = events[i];
        String eventName = event.getPropertyName();
        Object oldValue = event.getOldValue();
        Object newValue = event.getNewValue();
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "In JMSConfigListener " + eventName + oldValue + newValue);
        }
        if (oldValue != null && oldValue.equals(newValue)) {
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "Event " + eventName + " did not change existing value of " + oldValue);
            }
            continue;
        }
        if (event.getSource().toString().indexOf("connectors.jms.config.JmsService") != -1) {
            boolean notifyFlag = true;
            if (oldValue != null && newValue == null && "jms-host".equals(event.getPropertyName())) {
                JmsHost jmsHost = (JmsHost) oldValue;
                String name = ActiveJmsResourceAdapter.GRIZZLY_PROXY_PREFIX + jmsHost.getName();
                ActiveJmsResourceAdapter adapter = Globals.get(ActiveJmsResourceAdapter.class);
                if (adapter.getGrizzlyListeners().contains(name)) {
                    GrizzlyService grizzlyService = Globals.get(GrizzlyService.class);
                    synchronized (adapter.getGrizzlyListeners()) {
                        if (_logger.isLoggable(Level.FINE)) {
                            _logger.log(Level.FINE, "Stopping Grizzly proxy " + name);
                        }
                        grizzlyService.removeNetworkProxy(name);
                        adapter.getGrizzlyListeners().remove(name);
                    }
                    notifyFlag = false;
                }
            }
            if (notifyFlag) {
                UnprocessedChangeEvent uchangeEvent = new UnprocessedChangeEvent(event, "restart required");
                unprocessedEvents.add(uchangeEvent);
            }
        } else if (event.getSource().toString().indexOf("connectors.jms.config.JmsHost") != -1) {
            if (oldValue == null && newValue != null && "name".equals(event.getPropertyName())) {
                JmsProviderLifecycle lifecycle = Globals.get(JmsProviderLifecycle.class);
                JmsHost jmsHost = (JmsHost) event.getSource();
                if (ActiveJmsResourceAdapter.EMBEDDED.equalsIgnoreCase(jmsService.getType())) {
                    ActiveJmsResourceAdapter adapter = Globals.get(ActiveJmsResourceAdapter.class);
                    if (!adapter.getDoBind()) {
                        if (Boolean.valueOf(jmsHost.getLazyInit())) {
                            String host = null;
                            if (jmsHost.getHost() != null && "localhost".equals(jmsHost.getHost())) {
                                host = "0.0.0.0";
                            } else {
                                host = jmsHost.getHost();
                            }
                            try {
                                GrizzlyService grizzlyService = Globals.get(GrizzlyService.class);
                                NetworkListener dummy = new DummyNetworkListener();
                                dummy.setPort(jmsHost.getPort());
                                dummy.setAddress(host);
                                dummy.setType("proxy");
                                dummy.setProtocol(ActiveJmsResourceAdapter.JMS_SERVICE);
                                dummy.setTransport("tcp");
                                String name = ActiveJmsResourceAdapter.GRIZZLY_PROXY_PREFIX + jmsHost.getName();
                                dummy.setName(name);
                                synchronized (adapter.getGrizzlyListeners()) {
                                    if (_logger.isLoggable(Level.FINE)) {
                                        _logger.log(Level.FINE, "Starting Grizzly proxy " + name + " on port " + jmsHost.getPort());
                                    }
                                    grizzlyService.createNetworkProxy(dummy);
                                    adapter.getGrizzlyListeners().add(name);
                                }
                                return unprocessedEvents.size() > 0 ? new UnprocessedChangeEvents(unprocessedEvents) : null;
                            } catch (Exception e) {
                                LogHelper.log(_logger, Level.WARNING, JMSLoggerInfo.GRIZZLY_START_FAILURE, e);
                            }
                        }
                    }
                }
            }
        }
        if ("JMS_PROVIDER_PORT".equals(newValue)) {
            // The value is in the next event
            PropertyChangeEvent nextevent = events[i + 1];
            jmsProviderPort = (String) nextevent.getNewValue();
        }
        if (event.getSource() instanceof JmsService) {
            if (eventName.equals(ServerTags.MASTER_BROKER)) {
                String oldMB = oldValue != null ? oldValue.toString() : null;
                String newMB = newValue != null ? newValue.toString() : null;
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.log(Level.FINE, "Got JmsService Master Broker change event " + event.getSource() + " " + eventName + " " + oldMB + " " + newMB);
                }
                if (newMB != null) {
                    Server newMBServer = domain.getServerNamed(newMB);
                    if (newMBServer != null) {
                        Node node = domain.getNodeNamed(newMBServer.getNodeRef());
                        String newMasterBrokerPort = JmsRaUtil.getJMSPropertyValue(newMBServer);
                        if (newMasterBrokerPort == null)
                            newMasterBrokerPort = getDefaultJmsHost(jmsService).getPort();
                        String newMasterBrokerHost = node.getNodeHost();
                        aresourceAdapter.setMasterBroker(newMasterBrokerHost + ":" + newMasterBrokerPort);
                    }
                }
            }
        }
        if (eventName.equals(ServerTags.SERVER_REF)) {
            // if(event instanceof ServerRef){
            String oldServerRef = oldValue != null ? oldValue.toString() : null;
            String newServerRef = newValue != null ? newValue.toString() : null;
            if (oldServerRef != null && newServerRef == null && !thisServer.isDas()) {
                // instance has been deleted
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.log(Level.FINE, "Got Cluster change event for server_ref" + event.getSource() + " " + eventName + " " + oldServerRef + " " + null);
                }
                String url = getBrokerList();
                aresourceAdapter.setClusterBrokerList(url);
                break;
            }
        // 
        }
        // else skip
        if (event.getSource() instanceof Server) {
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "In JMSConfigListener - recieved cluster event " + event.getSource());
            }
            Server changedServer = (Server) event.getSource();
            if (thisServer.isDas())
                return null;
            if (jmsProviderPort != null) {
                String nodeName = changedServer.getNodeRef();
                String nodeHost = null;
                if (nodeName != null)
                    nodeHost = domain.getNodeNamed(nodeName).getNodeHost();
                String url = getBrokerList();
                url = url + ",mq://" + nodeHost + ":" + jmsProviderPort;
                aresourceAdapter.setClusterBrokerList(url);
                break;
            }
        }
    }
    return unprocessedEvents.size() > 0 ? new UnprocessedChangeEvents(unprocessedEvents) : null;
}
Also used : UnprocessedChangeEvents(org.jvnet.hk2.config.UnprocessedChangeEvents) DummyNetworkListener(com.sun.enterprise.v3.services.impl.DummyNetworkListener) PropertyChangeEvent(java.beans.PropertyChangeEvent) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) UnprocessedChangeEvent(org.jvnet.hk2.config.UnprocessedChangeEvent) ServerContext(org.glassfish.internal.api.ServerContext) GrizzlyService(com.sun.enterprise.v3.services.impl.GrizzlyService) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost) DummyNetworkListener(com.sun.enterprise.v3.services.impl.DummyNetworkListener) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 8 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class CreateJMSHost method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the paramter names and the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    Config targetConfig = domain.getConfigNamed(target);
    if (targetConfig != null)
        config = targetConfig;
    Server targetServer = domain.getServerNamed(target);
    // String configRef = targetServer.getConfigRef();
    if (targetServer != null) {
        config = domain.getConfigNamed(targetServer.getConfigRef());
    }
    com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
    if (cluster != null) {
        config = domain.getConfigNamed(cluster.getConfigRef());
    }
    if (jmsHostName == null) {
        report.setMessage(localStrings.getLocalString("create.jms.host.noJmsHost", "No JMS Host name specified."));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    JmsService jmsservice = config.getExtensionByType(JmsService.class);
    // ensure we don't already have one of this name before creating it.
    for (JmsHost jmsHost : jmsservice.getJmsHost()) {
        if (jmsHostName.equals(jmsHost.getName())) {
            if (force) {
                ActionReport deleteReport = report.addSubActionsReport();
                ParameterMap parameters = new ParameterMap();
                parameters.set("DEFAULT", jmsHostName);
                parameters.set("target", target);
                commandRunner.getCommandInvocation("delete-jms-host", deleteReport, context.getSubject()).parameters(parameters).execute();
                if (ActionReport.ExitCode.FAILURE.equals(deleteReport.getActionExitCode())) {
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    return;
                }
                break;
            } else {
                report.setMessage(localStrings.getLocalString("create.jms.host.duplicate", "A JMS Host named {0} already exists.", jmsHostName));
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                return;
            }
        }
    }
    try {
        ConfigSupport.apply(new SingleConfigCode<JmsService>() {

            public Object run(JmsService param) throws PropertyVetoException, TransactionFailure {
                // TODO: need a way to create a JmsHost instance
                JmsHost jmsHost = param.createChild(JmsHost.class);
                jmsHost.setAdminPassword(mqpassword);
                jmsHost.setAdminUserName(mquser);
                jmsHost.setName(jmsHostName);
                jmsHost.setHost(mqhost);
                jmsHost.setPort(mqport);
                if (props != null) {
                    for (Map.Entry e : props.entrySet()) {
                        Property prop = jmsHost.createChild(Property.class);
                        prop.setName((String) e.getKey());
                        prop.setValue((String) e.getValue());
                        jmsHost.getProperty().add(prop);
                    }
                }
                param.getJmsHost().add(jmsHost);
                return jmsHost;
            }
        }, jmsservice);
    } catch (TransactionFailure tfe) {
        report.setMessage(localStrings.getLocalString("create.jms.host.fail", "Unable to create jms host {0}.", jmsHostName) + " " + tfe.getLocalizedMessage());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(tfe);
    }
    report.setMessage(localStrings.getLocalString("create.jms.host.success", "Jms Host {0} created.", jmsHostName));
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) ParameterMap(org.glassfish.api.admin.ParameterMap) ActionReport(org.glassfish.api.ActionReport) com.sun.enterprise.config.serverbeans(com.sun.enterprise.config.serverbeans) PropertyVetoException(java.beans.PropertyVetoException) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost) Property(org.jvnet.hk2.config.types.Property)

Example 9 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.

the class JMSDestination method getMQJMXConnectorInfos.

protected MQJMXConnectorInfo[] getMQJMXConnectorInfos(final String target, final Config config, final ServerContext serverContext, final Domain domain, ConnectorRuntime connectorRuntime) throws ConnectorRuntimeException {
    try {
        final JmsService jmsService = config.getExtensionByType(JmsService.class);
        ActiveJmsResourceAdapter air = getMQAdapter(connectorRuntime);
        final Class mqRAClassName = air.getResourceAdapter().getClass();
        final CommandTarget ctarget = this.getTypeForTarget(target);
        MQJMXConnectorInfo mqjmxForServer = (MQJMXConnectorInfo) java.security.AccessController.doPrivileged(new java.security.PrivilegedExceptionAction() {

            public java.lang.Object run() throws Exception {
                if (ctarget == CommandTarget.CLUSTER || ctarget == CommandTarget.CLUSTERED_INSTANCE) {
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE, "Getting JMX connector for" + " cluster target " + target);
                    }
                    return _getMQJMXConnectorInfoForCluster(target, jmsService, mqRAClassName, serverContext);
                } else {
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE, "Getting JMX connector for" + " standalone target " + target);
                    }
                    return _getMQJMXConnectorInfo(target, jmsService, mqRAClassName, serverContext, config, domain);
                }
            }
        });
        return new MQJMXConnectorInfo[] { mqjmxForServer };
    } catch (Exception e) {
        // e.printStackTrace();
        ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
        cre.initCause(e);
        throw cre;
    }
}
Also used : ActiveJmsResourceAdapter(com.sun.enterprise.connectors.jms.system.ActiveJmsResourceAdapter) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) CommandTarget(org.glassfish.config.support.CommandTarget) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 10 with JmsService

use of com.sun.enterprise.connectors.jms.config.JmsService 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)

Aggregations

JmsService (com.sun.enterprise.connectors.jms.config.JmsService)22 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)10 JmsHost (com.sun.enterprise.connectors.jms.config.JmsHost)10 PrivilegedActionException (java.security.PrivilegedActionException)6 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)6 ActionReport (org.glassfish.api.ActionReport)6 PropertyVetoException (java.beans.PropertyVetoException)5 URISyntaxException (java.net.URISyntaxException)5 ExecutionException (java.util.concurrent.ExecutionException)5 MultiException (org.glassfish.hk2.api.MultiException)5 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)4 com.sun.enterprise.config.serverbeans (com.sun.enterprise.config.serverbeans)3 Cluster (com.sun.enterprise.config.serverbeans.Cluster)3 Server (com.sun.enterprise.config.serverbeans.Server)3 ServerContext (org.glassfish.internal.api.ServerContext)3 Domain (com.sun.enterprise.config.serverbeans.Domain)2 JmsAvailability (com.sun.enterprise.connectors.jms.config.JmsAvailability)2 ActiveJmsResourceAdapter (com.sun.enterprise.connectors.jms.system.ActiveJmsResourceAdapter)2 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)2 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)2