Java 类javax.management.remote.JMXConnectorServer 实例源码

项目:OpenJSharp    文件:Agent.java   
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
项目:OperatieBRP    文件:JMXAgent.java   
/**
 * Maak een connector server instantie.
 *
 * @return connector server
 * @throws IOException bij fouten
 */
private JMXConnectorServer createConnectorServer() throws IOException {
    final Properties configuration = readConfiguration();
    final MBeanServer server = locateMBeanServer();

    final JMXServiceURL url = new JMXServiceURL(SimpleJmx.PROTOCOL,
            configuration.getProperty("jmx.host", DEFAULT_HOST), Integer.parseInt(configuration.getProperty("jmx.port", DEFAULT_PORT)));

    final Map<String,Object> environment = new HashMap<>();
    Properties authentication = new Properties();
    authentication.setProperty("admin", "admin");
    environment.put("jmx.remote.authenticator", new PropertiesAuthenticator(authentication));
    environment.put("jmx.remote.accesscontroller", new AllAccessController());

    return JMXConnectorServerFactory.newJMXConnectorServer(url, environment, server);
}
项目:jdk8u-jdk    文件:Agent.java   
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
项目:jdk8u-jdk    文件:ListenerScaleTest.java   
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
项目:jdk8u-jdk    文件:RMIConnectorLogAttributesTest.java   
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
项目:jdk8u-jdk    文件:ProviderTest.java   
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
项目:openjdk-jdk10    文件:Agent.java   
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
项目:openjdk-jdk10    文件:ListenerScaleTest.java   
public static void main(String[] args) throws Exception {
    if (Platform.isDebugBuild()) {
        System.out.println("Running on a debug build. Performance test not applicable. Skipping.");
        return;
    }
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
项目:openjdk-jdk10    文件:RMIConnectorLogAttributesTest.java   
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
项目:openjdk-jdk10    文件:ProviderTest.java   
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
项目:openjdk9    文件:Agent.java   
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
项目:openjdk9    文件:ListenerScaleTest.java   
public static void main(String[] args) throws Exception {
    if (Platform.isDebugBuild()) {
        System.out.println("Running on a debug build. Performance test not applicable. Skipping.");
        return;
    }
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
项目:openjdk9    文件:RMIConnectorLogAttributesTest.java   
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
项目:openjdk9    文件:ProviderTest.java   
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
项目:spring4-understanding    文件:MBeanServerConnectionFactoryBeanTests.java   
@Test
public void testTestValidConnection() throws Exception {
    Assume.group(TestGroup.JMXMP);
    JMXConnectorServer connectorServer = getConnectorServer();
    connectorServer.start();

    try {
        MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean();
        bean.setServiceUrl(serviceUrl);
        bean.afterPropertiesSet();

        try {
            MBeanServerConnection connection = bean.getObject();
            assertNotNull("Connection should not be null", connection);

            // perform simple MBean count test
            assertEquals("MBean count should be the same", getServer().getMBeanCount(), connection.getMBeanCount());
        } finally {
            bean.destroy();
        }
    } finally {
        connectorServer.stop();
    }
}
项目:spring4-understanding    文件:MBeanServerConnectionFactoryBeanTests.java   
@Test
public void testTestWithLazyConnection() throws Exception {
    Assume.group(TestGroup.JMXMP);
    MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean();
    bean.setServiceUrl(serviceUrl);
    bean.setConnectOnStartup(false);
    bean.afterPropertiesSet();

    MBeanServerConnection connection = bean.getObject();
    assertTrue(AopUtils.isAopProxy(connection));

    JMXConnectorServer connector = null;
    try {
        connector = getConnectorServer();
        connector.start();
        assertEquals("Incorrect MBean count", getServer().getMBeanCount(), connection.getMBeanCount());
    } finally {
        bean.destroy();
        if (connector != null) {
            connector.stop();
        }
    }
}
项目:jdk8u_jdk    文件:Agent.java   
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
项目:jdk8u_jdk    文件:ListenerScaleTest.java   
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
项目:jdk8u_jdk    文件:RMIConnectorLogAttributesTest.java   
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
项目:jdk8u_jdk    文件:ProviderTest.java   
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
项目:lookaside_java-1.8.0-openjdk    文件:Agent.java   
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ListenerScaleTest.java   
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:RMIConnectorLogAttributesTest.java   
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
项目:lookaside_java-1.8.0-openjdk    文件:ProviderTest.java   
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
项目:Keiko    文件:KeikoSniffer.java   
private static void createJSR160Server() throws RemoteException, MalformedURLException,
    IOException {
    // Create RMI registry needed for JSR-160 connectors
    LocateRegistry.createRegistry(8998);

    // Create MBeanServer
    final MBeanServer server = MBeanServerFactory.createMBeanServer();

    // Create the JMXConnectorServer
    final JMXServiceURL address =
        new JMXServiceURL("service:jmx:rmi://localhost/jndi/rmi://localhost:8998/jmxconnector");
    // The environment map
    // Map environment = new HashMap();
    // environment.put(JMXConnectorServer.AUTHENTICATOR, new
    // FooAuthenticator());

    final JMXConnectorServer connectorServer =
        JMXConnectorServerFactory.newJMXConnectorServer(address, null, server);

    // Start the JMXConnectorServer
    connectorServer.start();
}
项目:cacheonix-core    文件:Server.java   
public static void main(String[] args) throws Exception
{
   // The MBeanServer
   MBeanServer server = MBeanServerFactory.createMBeanServer();

   // Pass null as the host name to tell JMXServiceURL to default to InetAddress.getLocalHost().getHostName()
   JMXServiceURL url = new JMXServiceURL("hessian+ssl", null, 8443, "/hessianssl");

   // Replace the value of the configuration with the file path of the configuration file
   Map serverEnv = new HashMap();
   serverEnv.put(HTTPConnectorServer.WEB_CONTAINER_CONFIGURATION, "<your-web-container-configuration>");
   JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, serverEnv, server);
   connectorServer.start();

   System.out.println("Server up and running " + connectorServer + " on " + url);
}
项目:cacheonix-core    文件:Server.java   
public static void main(String[] args) throws Exception
{
   // The MBeanServer
   MBeanServer server = MBeanServerFactory.createMBeanServer();

   // Register and start the rmiregistry MBean, needed by JSR 160 RMIConnectorServer
   ObjectName namingName = ObjectName.getInstance("naming:type=rmiregistry");
   server.createMBean("mx4j.tools.naming.NamingService", namingName, null);
   server.invoke(namingName, "start", null, null);
   int namingPort = ((Integer)server.getAttribute(namingName, "Port")).intValue();

   String jndiPath = "/jmxconnector";
   JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost/jndi/rmi://localhost:" + namingPort + jndiPath);

   // Create and start the RMIConnectorServer
   JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
   connectorServer.start();

   System.out.println("Server up and running");
}
项目:cacheonix-core    文件:Server.java   
public static void main(String[] args) throws Exception
{
   // The address of the connector server
   JMXServiceURL url = new JMXServiceURL("rmi", "localhost", 0, "/jndi/jmx");

   // No need of environment variables or the MBeanServer at this point
   JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, null);
   ObjectName cntorServerName = ObjectName.getInstance(":service=" + JMXConnectorServer.class.getName() + ",protocol=" + url.getProtocol());

   MBeanServer server = MBeanServerFactory.createMBeanServer("remote.notification.example");
   // Register the connector server as MBean
   server.registerMBean(cntorServer, cntorServerName);

   // The rmiregistry needed to bind the RMI stub
   NamingService naming = new NamingService();
   ObjectName namingName = ObjectName.getInstance(":service=" + NamingService.class.getName());
   server.registerMBean(naming, namingName);
   naming.start();

   // Start the connector server
   cntorServer.start();

   System.out.println("Server up and running");
}
项目:Cojac    文件:CojacReferences.java   
private void registerInstrumentationStats(MBeanServer mbServer, InstrumentationStats stats) {
    try {
        String name = args.getValue(Arg.JMX_NAME);
        int port = Integer.parseInt(args.getValue(Arg.JMX_PORT));
        String host = args.getValue(Arg.JMX_HOST);
        ObjectName statsName = new ObjectName("COJAC:type=InstrumentationMXBean,name=" +
                name);
        LocateRegistry.createRegistry(port);
        StringBuilder sb = new StringBuilder("/jndi/rmi://").append(host).append(":").append(port);
        sb.append("/").append(name);
        JMXServiceURL url = new JMXServiceURL("rmi", null, 0, sb.toString());
        JMXConnectorServer jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbServer);
        jmxConnectorServer.start();
        if (!mbServer.isRegistered(statsName)) {
            mbServer.registerMBean(stats, statsName);
        }
    } catch (MalformedObjectNameException | NullPointerException
            | InstanceAlreadyExistsException
            | MBeanRegistrationException | NotCompliantMBeanException
            | IOException e) {
        e.printStackTrace();
    }
}
项目:GemFireLite    文件:GemliteAgent.java   
public void startRMIConnector(int jmxPort)
{
  try
  {
    LogUtil.getCoreLog().info("RMI port:"+jmxPort);
    ServerConfigHelper.setProperty("JMX_RMI_PORT", ""+jmxPort);
    MBeanServer mbs= ManagementFactory.getPlatformMBeanServer();
    ObjectName namingName = ObjectName.getInstance("naming:type=rmiregistry");
    mbs.registerMBean(new NamingService(jmxPort), namingName);
    mbs.invoke(namingName, "start", null, null);
    String jndiPath = "/jmxconnector";
    String bindIp = ServerConfigHelper.getProperty(ITEMS.BINDIP.name());
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+bindIp+":" + jmxPort + jndiPath);
    JMXConnectorServer connector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);

    ObjectName connectorName = null;
    connectorName = new ObjectName("Gemlite:name=RMIConnector");
    mbs.registerMBean(connector, connectorName);
    connector.start();
  }
  catch (Exception e)
  {
    LogUtil.getCoreLog().error("Error start rmi connector",e);
  }
}
项目:yummy-xml-UI    文件:Numen.java   
private boolean initConnectorServer() {
    try {
        MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
        ObjectName numenName = new ObjectName(NumenMonitor.NUMEN_MONITOR_JMX_BEAN_NAME);
        mbeanServer.registerMBean(new NumenMonitor(), numenName);
        //about url referring to http://stackoverflow.com/questions/2768087/explain-jmx-url
        //protocol:rmi, host:localhot, port:random, url:/jndi/rmi://localhost:1099/jmxrmi
        LocateRegistry.createRegistry(CommonConstants.WATCHDOG_JMX_RMI_PORT);
        JMXServiceURL serviceURL = new JMXServiceURL(CommonConstants.WATCHDOG_JMX_RMI_URL);
        JMXConnectorServer jcs = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, null, mbeanServer);
        jcs.start();
        return true;
    } catch (MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException | IOException ex) {
        getLogger(Numen.class.getName()).log(Level.SEVERE,
                "fail to start Numen Deamon JMX Connector Server due to :\n{0}", ex.getMessage());
        return false;
    }
}
项目:infobip-open-jdk-8    文件:Agent.java   
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
项目:infobip-open-jdk-8    文件:ListenerScaleTest.java   
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
项目:infobip-open-jdk-8    文件:ProviderTest.java   
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
项目:jdk8u-dev-jdk    文件:Agent.java   
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
项目:jdk8u-dev-jdk    文件:ListenerScaleTest.java   
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
项目:jdk8u-dev-jdk    文件:ProviderTest.java   
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
项目:jdk7-jdk    文件:ListenerScaleTest.java   
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
项目:jdk7-jdk    文件:IIOPURLTest.java   
public static void main(String[] args) throws Exception {
    JMXServiceURL inputAddr =
        new JMXServiceURL("service:jmx:iiop://");
    JMXConnectorServer s =
        JMXConnectorServerFactory.newJMXConnectorServer(inputAddr, null,
                                                        null);
    MBeanServer mbs = MBeanServerFactory.createMBeanServer();
    mbs.registerMBean(s, new ObjectName("a:b=c"));
    s.start();
    JMXServiceURL outputAddr = s.getAddress();
    if (!outputAddr.getURLPath().startsWith("/ior/IOR:")) {
        System.out.println("URL path should start with \"/ior/IOR:\": " +
                           outputAddr);
        System.exit(1);
    }
    System.out.println("IIOP URL path looks OK: " + outputAddr);
    JMXConnector c = JMXConnectorFactory.connect(outputAddr);
    System.out.println("Successfully got default domain: " +
                       c.getMBeanServerConnection().getDefaultDomain());
    c.close();
    s.stop();
}
项目:openjdk-source-code-learn    文件:ConnectorBootstrap.java   
/**
 * Initializes and starts the JMX Connector Server.
 * If the com.sun.management.jmxremote.port property is not defined,
 * simply return. Otherwise, attempts to load the config file, and
 * then calls {@link #initialize(java.lang.String, java.util.Properties)}.
 *
 **/
public static synchronized JMXConnectorServer initialize() {

    // Load a new management properties
    final Properties props = Agent.loadManagementProperties();
    if (props == null) {
        return null;
    }

    final String portStr = props.getProperty(PropertyNames.PORT);


    // System.out.println("initializing: {port=" + portStr + ",
    //                     properties="+props+"}");
    return initialize(portStr, props);
}