Search in sources :

Example 1 with JmxConnector

use of com.sun.enterprise.config.serverbeans.JmxConnector in project Payara by payara.

the class ReferenceConstrainTest method jmxConnectorAuthRealmRefInvalid.

@Test
public void jmxConnectorAuthRealmRefInvalid() throws TransactionFailure {
    JmxConnector jmxConnector = habitat.getService(JmxConnector.class, "system");
    assertNotNull(jmxConnector);
    ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(jmxConnector);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("auth-realm-name", "realm-not-exist");
    changes.put(serverConfig, configChanges);
    try {
        ConfigSupport cs = getHabitat().getService(ConfigSupport.class);
        cs.apply(changes);
        fail("Can not reach this point");
    } catch (TransactionFailure tf) {
        ConstraintViolationException cv = findConstrViolation(tf);
        assertNotNull(cv);
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) HashMap(java.util.HashMap) ConstraintViolationException(javax.validation.ConstraintViolationException) JmxConnector(com.sun.enterprise.config.serverbeans.JmxConnector) ConfigBean(org.jvnet.hk2.config.ConfigBean) HashMap(java.util.HashMap) Map(java.util.Map) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 2 with JmxConnector

use of com.sun.enterprise.config.serverbeans.JmxConnector in project Payara by payara.

the class CreateSsl method addSslToJMXConnector.

private void addSslToJMXConnector(Config config, ActionReport report) {
    AdminService adminService = config.getAdminService();
    // ensure we have the specified listener
    JmxConnector jmxConnector = null;
    for (JmxConnector jmxConn : adminService.getJmxConnector()) {
        if (jmxConn.getName().equals(listenerId)) {
            jmxConnector = jmxConn;
        }
    }
    if (jmxConnector == null) {
        report.setMessage(LOCAL_STRINGS.getLocalString("create.ssl.jmx.notfound", "JMX Connector named {0} to which this ssl element is " + "being added does not exist.", listenerId));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    if (jmxConnector.getSsl() != null) {
        report.setMessage(LOCAL_STRINGS.getLocalString("create.ssl.jmx.alreadyExists", "IIOP Listener named {0} to which this ssl element is " + "being added already has an ssl element.", listenerId));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        ConfigSupport.apply(new SingleConfigCode<JmxConnector>() {

            @Override
            public Object run(JmxConnector param) throws PropertyVetoException, TransactionFailure {
                Ssl newSsl = param.createChild(Ssl.class);
                populateSslElement(newSsl);
                param.setSsl(newSsl);
                return newSsl;
            }
        }, jmxConnector);
    } catch (TransactionFailure e) {
        reportError(report, e);
    }
    reportSuccess(report);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) AdminService(com.sun.enterprise.config.serverbeans.AdminService) JmxConnector(com.sun.enterprise.config.serverbeans.JmxConnector) Ssl(org.glassfish.grizzly.config.dom.Ssl)

Example 3 with JmxConnector

use of com.sun.enterprise.config.serverbeans.JmxConnector in project Payara by payara.

the class ReferenceConstrainTest method jmxConnectorAuthRealmRefValid.

@Test
public void jmxConnectorAuthRealmRefValid() throws TransactionFailure {
    JmxConnector jmxConnector = habitat.getService(JmxConnector.class, "system");
    assertNotNull(jmxConnector);
    ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(jmxConnector);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("auth-realm-name", "file");
    changes.put(serverConfig, configChanges);
    try {
        ConfigSupport cs = getHabitat().getService(ConfigSupport.class);
        cs.apply(changes);
    } catch (TransactionFailure tf) {
        fail("Can not reach this point");
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) HashMap(java.util.HashMap) JmxConnector(com.sun.enterprise.config.serverbeans.JmxConnector) ConfigBean(org.jvnet.hk2.config.ConfigBean) HashMap(java.util.HashMap) Map(java.util.Map) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 4 with JmxConnector

use of com.sun.enterprise.config.serverbeans.JmxConnector in project Payara by payara.

the class NodeAgentConfigUpgrade method postConstruct.

@Override
public void postConstruct() {
    final NodeAgents nodeAgents = domain.getNodeAgents();
    if (nodeAgents == null) {
        createDefaultNodeList();
        return;
    }
    final List<NodeAgent> agList = nodeAgents.getNodeAgent();
    if (agList.isEmpty()) {
        createDefaultNodeList();
        return;
    }
    try {
        ConfigSupport.apply(new SingleConfigCode<Domain>() {

            @Override
            public Object run(Domain d) throws PropertyVetoException, TransactionFailure {
                Nodes nodes = d.createChild(Nodes.class);
                Transaction t = Transaction.getTransaction(d);
                if (t == null)
                    return null;
                for (NodeAgent na : agList) {
                    String host = null;
                    Node node = nodes.createChild(Node.class);
                    node.setName(na.getName());
                    node.setType("CONFIG");
                    JmxConnector jc = na.getJmxConnector();
                    if (jc != null) {
                        // get the properties and see if host name is specified
                        List<Property> agentProp = jc.getProperty();
                        for (Property p : agentProp) {
                            String name = p.getName();
                            if (name.equals("client-hostname")) {
                                // create the node with a host name
                                node.setNodeHost(p.getValue());
                                node.setInstallDir("${com.sun.aas.productRoot}");
                            }
                        }
                    }
                    nodes.getNode().add(node);
                }
                // Now add the builtin localhost node
                createDefaultNode(d, nodes);
                d.setNodes(nodes);
                List<Server> serverList = servers.getServer();
                if (serverList.isEmpty())
                    return null;
                for (Server s : serverList) {
                    s = t.enroll(s);
                    s.setNodeRef(s.getNodeAgentRef());
                    s.setNodeAgentRef(null);
                }
                // remove the node-agent element by setting to null
                d.setNodeAgents(null);
                return null;
            }
        }, domain);
    } catch (Exception e) {
        Logger.getAnonymousLogger().log(Level.SEVERE, "Failure while upgrading node-agent from V2 to V3", e);
        throw new RuntimeException(e);
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Server(com.sun.enterprise.config.serverbeans.Server) Node(com.sun.enterprise.config.serverbeans.Node) NodeAgent(com.sun.enterprise.config.serverbeans.NodeAgent) JmxConnector(com.sun.enterprise.config.serverbeans.JmxConnector) NodeAgents(com.sun.enterprise.config.serverbeans.NodeAgents) Nodes(com.sun.enterprise.config.serverbeans.Nodes) PropertyVetoException(java.beans.PropertyVetoException) PropertyVetoException(java.beans.PropertyVetoException) Domain(com.sun.enterprise.config.serverbeans.Domain) Property(org.jvnet.hk2.config.types.Property)

Example 5 with JmxConnector

use of com.sun.enterprise.config.serverbeans.JmxConnector 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

JmxConnector (com.sun.enterprise.config.serverbeans.JmxConnector)5 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)4 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)2 PropertyVetoException (java.beans.PropertyVetoException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Test (org.junit.Test)2 ConfigBean (org.jvnet.hk2.config.ConfigBean)2 ConfigSupport (org.jvnet.hk2.config.ConfigSupport)2 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 AdminService (com.sun.enterprise.config.serverbeans.AdminService)1 Domain (com.sun.enterprise.config.serverbeans.Domain)1 Node (com.sun.enterprise.config.serverbeans.Node)1 NodeAgent (com.sun.enterprise.config.serverbeans.NodeAgent)1 NodeAgents (com.sun.enterprise.config.serverbeans.NodeAgents)1 Nodes (com.sun.enterprise.config.serverbeans.Nodes)1 Server (com.sun.enterprise.config.serverbeans.Server)1 URISyntaxException (java.net.URISyntaxException)1 PrivilegedActionException (java.security.PrivilegedActionException)1 ExecutionException (java.util.concurrent.ExecutionException)1