当前位置: 首页>>代码示例>>Java>>正文


Java JMXConnectorServerFactory.newJMXConnectorServer方法代码示例

本文整理汇总了Java中javax.management.remote.JMXConnectorServerFactory.newJMXConnectorServer方法的典型用法代码示例。如果您正苦于以下问题:Java JMXConnectorServerFactory.newJMXConnectorServer方法的具体用法?Java JMXConnectorServerFactory.newJMXConnectorServer怎么用?Java JMXConnectorServerFactory.newJMXConnectorServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.management.remote.JMXConnectorServerFactory的用法示例。


在下文中一共展示了JMXConnectorServerFactory.newJMXConnectorServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dotest

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
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());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:ProviderTest.java

示例2: main

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:ListenerScaleTest.java

示例3: createConnectorServer

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:22,代码来源:JMXAgent.java

示例4: main

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:18,代码来源:ListenerScaleTest.java

示例5: startServer

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
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;
}
 
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:18,代码来源:RMIConnectorLogAttributesTest.java

示例6: createJSR160Server

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
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();
}
 
开发者ID:InstantCom,项目名称:Keiko,代码行数:23,代码来源:KeikoSniffer.java

示例7: lifecycleEvent

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
@Override
public synchronized void lifecycleEvent(final LifecycleEvent event) {
    try {
        if (server == null && Lifecycle.START_EVENT.equals(event.getType())) {
            serviceURL = new JMXServiceURL(protocol, host, port, urlPath);
            server = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, null,
                                                ManagementFactory.getPlatformMBeanServer());
            server.start();
            LOGGER.info("Started JMX server: " + serviceURL.toString());
        } else if (server != null && Lifecycle.STOP_EVENT.equals(event.getType())) {
            server.stop();
            server = null;
            LOGGER.info("Stopped JMX server: " + serviceURL.toString());
        }
    } catch (final Exception e) {
        throw new JMXException(e);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:19,代码来源:JMXServerListener.java

示例8: assertJmxEquals

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
protected void assertJmxEquals(String attributeName, Object attributeValue) throws Exception {
    JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(new JMXServiceURL("service:jmx:rmi://"),
                                                                            null,
                                                                            ManagementFactory.getPlatformMBeanServer());
    cs.start();

    JMXConnector cc = null;

    try {
        cc = JMXConnectorFactory.connect(cs.getAddress());
        MBeanServerConnection mbsc = cc.getMBeanServerConnection();
        ObjectName objectName = JmxUtils.createObjectName(JmxUtils.getPackageName(failureDetector.getClass()),
                                                          failureDetector.getClass()
                                                                         .getSimpleName());

        Object availableNodes = mbsc.getAttribute(objectName, attributeName);
        assertEquals(attributeValue, availableNodes);
    } finally {
        if(cc != null)
            cc.close();

        cs.stop();
    }
}
 
开发者ID:we7,项目名称:voldemort,代码行数:25,代码来源:AbstractFailureDetectorTest.java

示例9: main

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    JMXServiceURL inputAddr =
        new JMXServiceURL("service:jmx:iiop://");
    JMXConnectorServer s;
    try {
        s = JMXConnectorServerFactory.newJMXConnectorServer(inputAddr, null, null);
    } catch (java.net.MalformedURLException x) {
        try {
            Class.forName("javax.management.remote.rmi._RMIConnectionImpl_Tie");
            throw new RuntimeException("MalformedURLException thrown but iiop appears to be supported");
        } catch (ClassNotFoundException expected) { }
        System.out.println("IIOP protocol not supported, test skipped");
        return;
    }
    MBeanServer mbs = MBeanServerFactory.createMBeanServer();
    mbs.registerMBean(s, new ObjectName("a:b=c"));
    s.start();
    JMXServiceURL outputAddr = s.getAddress();
    if (!outputAddr.getURLPath().startsWith("/ior/IOR:")) {
        throw new RuntimeException("URL path should start with \"/ior/IOR:\": " +
                                   outputAddr);
    }
    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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:IIOPURLTest.java

示例10: setUp

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
public static void setUp() throws IOException {
    MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer();
    
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();

   JMXServiceURL addr = cs.getAddress();
    
   cc = JMXConnectorFactory.connect(addr);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:12,代码来源:JMXEnv.java

示例11: start

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:Server.java

示例12: buildJmxConnector

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
/**
 * Create a JMXMP Connector.
 * @param startPort startport to look for an open port
 * @param maxRange maximum port scan range
 * @param mbs desired mbean server to register to
 * @return JmxConnectorServer that could be started
 * @throws IOException io exception if something bad happens
 */
public static JMXConnectorServer buildJmxConnector(final int startPort, final int maxRange, final MBeanServer mbs)
    throws IOException {
    final int nextOpenPort = PortScanner.getNextPort(startPort,30);
    log.log(Level.INFO, "[PORTSCAN]: using port " + nextOpenPort + " for next jmx interface");
    final JMXServiceURL url = new JMXServiceURL("jmxmp",null, nextOpenPort);
    final Map<String, Object> environment = new HashMap<>();
    final JMXConnectorServer connector = JMXConnectorServerFactory.newJMXConnectorServer(url,environment,mbs);
    return connector;
}
 
开发者ID:deB4SH,项目名称:Byter,代码行数:18,代码来源:JmxConnectionHelper.java

示例13: call

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
public MBeanServerConnection call() {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    try {
        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
        JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(
                url, null, mbs);
        cs.start();
        JMXServiceURL addr = cs.getAddress();
        connector = JMXConnectorFactory.connect(addr);
        return connector.getMBeanServerConnection();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:OldMBeanServerTest.java

示例14: lifecycleEvent

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
@Override
public void lifecycleEvent(final LifecycleEvent event)
{

    try
    {

        // START
        if (Lifecycle.START_EVENT == event.getType())
        {
            log.debug("Start JMXMP");

            cs = JMXConnectorServerFactory.newJMXConnectorServer(
                new JMXServiceURL("jmxmp", "0.0.0.0", port),
                null,
                ManagementFactory.getPlatformMBeanServer()
            );
            cs.start();

            log.info("Started JMXMP on port " + port);
        }

        // STOP
        else if (Lifecycle.STOP_EVENT == event.getType())
        {
            log.debug("Stopp JMXMP");

            cs.stop();

            log.info("Stopped JMXMP");
        }

    }
    catch (final Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:felixoldenburg,项目名称:jmxmp-lifecycle-listener,代码行数:39,代码来源:JMXMPLifecycleListener.java

示例15: jmxConnectorServerFactoryTests

import javax.management.remote.JMXConnectorServerFactory; //导入方法依赖的package包/类
private int jmxConnectorServerFactoryTests() {
    int errorCount = 0;
    echo("");
    echo(dashedMessage("Run JMXConnectorServerFactory Tests"));
    for (int i = 0; i < maps.length - 1; i++) {
        echo("\n>>> JMXConnectorServerFactory Test [" + i + "]");
        try {
            echo("\tMap = " + maps[i]);
            echo("\tCreate the MBean server");
            MBeanServer mbs = MBeanServerFactory.createMBeanServer();
            echo("\tCreate the RMI connector server");
            JMXServiceURL url =
                new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:" +
                                  port + "/JMXConnectorServerFactory" + i);
            JMXConnectorServer jmxcs =
                JMXConnectorServerFactory.newJMXConnectorServer(url,
                                                                maps[i],
                                                                mbs);
            echo("\tStart the RMI connector server");
            jmxcs.start();
            echo("\tCall RMIConnectorServer.toJMXConnector(Map)");
            jmxcs.toJMXConnector(maps[i]);
            echo("\tStop the RMI connector server");
            jmxcs.stop();
            echo("\tTest [" + i + "] PASSED!");
        } catch (Exception e) {
            errorCount++;
            echo("\tTest [" + i + "] FAILED!");
            e.printStackTrace(System.out);
        }
    }
    if (errorCount == 0) {
        echo("");
        echo(dashedMessage("JMXConnectorServerFactory Tests PASSED!"));
    } else {
        echo("");
        echo(dashedMessage("JMXConnectorServerFactory Tests FAILED!"));
    }
    return errorCount;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:41,代码来源:MapNullValuesTest.java


注:本文中的javax.management.remote.JMXConnectorServerFactory.newJMXConnectorServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。