Package javax.management.remote

Examples of javax.management.remote.JMXConnector


     * @throws IOException on connection failures
     */
    private void connect() throws IOException
    {
        JMXServiceURL jmxUrl = new JMXServiceURL(String.format(fmtUrl, host, port));
        JMXConnector jmxc = JMXConnectorFactory.connect(jmxUrl, null);
        mbeanServerConn = jmxc.getMBeanServerConnection();
       
        try
        {
            ObjectName name = new ObjectName(ssObjName);
            ssProxy = JMX.newMBeanProxy(mbeanServerConn, name, StorageServiceMBean.class);
View Full Code Here


     *
     * @exception JMException if a JMX error occurs.
     */ 
    public JMXConnector createConnection(String username, String password)
    throws JMException {
  JMXConnector jmxc = null;
  JMXServiceURL url = null;

  url = getJMXServiceURL();
  /*
  System.err.println("url: " + url);
View Full Code Here

        }
        return writerMap.get(key);
    }

    private void queryClients(String broker, String typeName, ExchangeMetric metric) throws Exception {
        JMXConnector connector;
        MBeanServerConnection connection;
        AdminConnectionFactory acf;
        acf = new AdminConnectionFactory();
        acf.setProperty(AdminConnectionConfiguration.imqAddress, broker);
        connector = acf.createConnection();

        try {
            connection = connector.getMBeanServerConnection();
            ObjectName exchangeManagerName = new ObjectName("com.sun.messaging.jms.server:" + typeName);
            String[] consumerIDs = (String[]) connection.invoke(exchangeManagerName, "getConsumerIDs", null, null);
            if(consumerIDs != null) {
                for(String consumerID : consumerIDs) {
                    if(consumerID != null) {
                        try {
                            CompositeData info = (CompositeData) connection.invoke(consumerManagerName, "getConsumerInfoByID", new Object[] {
                                consumerID
                            }, MBEAN_INVOKE_SIG);
                            if(info != null) {
                                metric.addConsumer(info.get("Host").toString());
                            }
                        }
                        catch(Exception e) {
                            logger.warn("cannot get info of consumer ID {}", consumerID);
                        }
                    }
                }
            }

            String[] producerIDs = (String[]) connection.invoke(exchangeManagerName, "getProducerIDs", null, null);
            if(producerIDs != null) {
                for(String producerID : producerIDs) {
                    if(producerID != null) {
                        try {
                            CompositeData info = (CompositeData) connection.invoke(producerManagerName, "getProducerInfoByID", new Object[] {
                                producerID
                            }, MBEAN_INVOKE_SIG);
                            if(info != null) {
                                metric.addProducer(info.get("Host").toString());
                            }
                        }
                        catch(Exception e) {
                            logger.warn("cannot get info of producer ID {}", producerID);
                        }
                    }
                }
            }
        }
        finally {
            connector.close();
        }
    }
View Full Code Here

            SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory();
            map.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf);
        }
        JMXServiceURL address = new JMXServiceURL(
                "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + connectorName);
        JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map);
        return jmxConnector.getMBeanServerConnection();
    }
View Full Code Here

            }
            if (log.isDebugEnabled()) {
                log.debug("Using JMXServiceURL with host=" + host + ", port=" + params.getPort() + ", secure=" + params.isSecure());
            }
            JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+ host +":"+params.getPort()+connectorName);
            JMXConnector jmxConnector = JMXConnectorFactory.connect(address, environment);
            RemoteDeploymentManager manager = getRemoteDeploymentManager();
            manager.init(jmxConnector, host);
            if(!manager.isSameMachine()) {
                manager.setAuthentication(username, password);
            }
View Full Code Here

    public void testSuccessAuthentication() throws Exception {
        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:2011/jmxrmi");
        Map env = new HashMap();
        env.put(JMXConnector.CREDENTIALS, new String[]{"admin", "activemq"});
        JMXConnector connector = JMXConnectorFactory.connect(url, env);
        assertAuthentication(connector);
    }
View Full Code Here

    }

    public void testFailAuthentication() throws Exception {
        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:2011/jmxrmi");
        try {
            JMXConnector connector = JMXConnectorFactory.connect(url, null);
            assertAuthentication(connector);
        } catch (SecurityException e) {
            return;
        }
        fail("Should have thrown an exception");
View Full Code Here

        h.put(Context.SECURITY_PRINCIPAL, "admin");
        h.put(Context.SECURITY_CREDENTIALS, "adminadmin");
        h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_CLASS_LOADER,cl);
        h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote");
       
        JMXConnector connector = JMXConnectorFactory.connect(serviceURL, h);
        MBeanServerConnection con = connector.getMBeanServerConnection();

       
    }
View Full Code Here

        Hashtable h = new Hashtable();
        h.put(Context.SECURITY_PRINCIPAL, "admin");
        h.put(Context.SECURITY_CREDENTIALS, "adminadmin");

        JMXConnector connector = JMXConnectorFactory.connect(serviceURL, h);
        MBeanServerConnection con = connector.getMBeanServerConnection();
//        for(ObjectName on : con.queryNames(null,null))
//            System.out.println(on);

        ObjectName on = new ObjectName("com.bea:Name=DeployerRuntime,Type=DeployerRuntime");
        DeployerRuntime dr = MBeanServerInvocationHandler.newProxyInstance(con, on, DeployerRuntime.class, false);
View Full Code Here

    private MBeanServerConnection getMBeanServerConnection() throws IOException {
        String[] credentials = new String[] { config.getJmxUsername(), config.getJmxPassword() };
        Map<String, ?> env = Collections.singletonMap(JMXConnector.CREDENTIALS, credentials);
        JMXServiceURL serviceURL = new JMXServiceURL(config.getJmxServiceURL());
        JMXConnector connector = JMXConnectorFactory.connect(serviceURL, env);
        return connector.getMBeanServerConnection();
    }
View Full Code Here

TOP

Related Classes of javax.management.remote.JMXConnector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.