Search in sources :

Example 1 with JMXStartupService

use of org.glassfish.admin.mbeanserver.JMXStartupService in project Payara by payara.

the class ActiveJmsResourceAdapter method isASRmiRegistryPortAvailable.

private boolean isASRmiRegistryPortAvailable(JmsRaUtil jmsraUtil) {
    if (_logger.isLoggable(Level.FINE))
        logFine("isASRmiRegistryPortAvailable - JMSService Type:" + jmsraUtil.getJMSServiceType());
    // AS RMI Registry. So the check below is not necessary.
    if (jmsraUtil.getJMSServiceType().equals(REMOTE) || jmsraUtil.getJMSServiceType().equals(LOCAL)) {
        return false;
    }
    try {
        JmxConnector jmxConnector = getJmxConnector();
        if (!"true".equals(jmxConnector.getEnabled()))
            return false;
        if ("true".equals(jmxConnector.getSecurityEnabled()))
            return false;
        // Attempt to detect JMXStartupService for RMI registry
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("Detecting JMXStartupService...");
        }
        JMXStartupService jmxservice = Globals.get(JMXStartupService.class);
        if (jmxservice == null)
            return false;
        jmxservice.waitUntilJMXConnectorStarted();
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("Found JMXStartupService");
        }
        String name = "rmi://" + getConfiguredRmiRegistryHost() + ":" + getConfiguredRmiRegistryPort() + "/jmxrmi";
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("Attempting to list " + name);
        }
        Naming.list(name);
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("List on " + name + " succeeded");
        }
        // return configured port only if RMI registry is available
        return true;
    } catch (Exception e) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("Failed to detect JMX RMI Registry: " + e.getMessage());
        }
        return false;
    }
}
Also used : JmxConnector(com.sun.enterprise.config.serverbeans.JmxConnector) JMXStartupService(org.glassfish.admin.mbeanserver.JMXStartupService) 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)

Aggregations

ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 JmxConnector (com.sun.enterprise.config.serverbeans.JmxConnector)1 URISyntaxException (java.net.URISyntaxException)1 PrivilegedActionException (java.security.PrivilegedActionException)1 ExecutionException (java.util.concurrent.ExecutionException)1 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)1 JMXStartupService (org.glassfish.admin.mbeanserver.JMXStartupService)1 MultiException (org.glassfish.hk2.api.MultiException)1