當前位置: 首頁>>代碼示例>>Java>>正文


Java JMXConnectorServerFactory類代碼示例

本文整理匯總了Java中javax.management.remote.JMXConnectorServerFactory的典型用法代碼示例。如果您正苦於以下問題:Java JMXConnectorServerFactory類的具體用法?Java JMXConnectorServerFactory怎麽用?Java JMXConnectorServerFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JMXConnectorServerFactory類屬於javax.management.remote包,在下文中一共展示了JMXConnectorServerFactory類的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: setUpClass

import javax.management.remote.JMXConnectorServerFactory; //導入依賴的package包/類
@BeforeClass
public static void setUpClass() throws RemoteException, MalformedURLException, IOException {
    Registry r = LocateRegistry.createRegistry(9999);
    mbs = MBeanServerFactory.createMBeanServer();

    person = new Test01_JavaIntrospection.Person("Alice Aho", 23);
    person.knows = new Test01_JavaIntrospection.Person("Bob", 30);
    
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/server");
    cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    if (cs == null) {
    	throw new RuntimeException("Could not setUpClass() for test! JMXConnectorServerFactory.newJMXConnectorServer FAILED (Returned null...)! Url: " + url + ", mbs: " + mbs);
    }
    cs.start();
    System.out.println("Registry created / JMX connector started.");
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:17,代碼來源:Test01_Jmx.java

示例3: getMBeanServer

import javax.management.remote.JMXConnectorServerFactory; //導入依賴的package包/類
/**
 * Returns MBeans server for the Pogamut Platform. All MBeans connected from
 * the platform should be registered in this server. There is also default
 * RMI connector for this server running on service:jmx:rmi:///jndi/rmi://localhost:9999/server
 * @return
 * @throws cz.cuni.amis.utils.exception.PogamutException
 */
@Override
public synchronized MBeanServer getMBeanServer() throws PogamutException {
    try {
        if (!registryCreated) {
            if (log.isLoggable(Level.WARNING)) log.warning("Creating registry at " + getRMIPort() + " ...");
            LocateRegistry.createRegistry(getRMIPort());
            registryCreated = true;
        }
        if (mBeanServer == null) {
            if (log.isLoggable(Level.WARNING)) log.warning("Starting MBean server.");
            //start a RMI registry                
            mBeanServer = new PogamutMBeanServer();

            // also create connector for this server, server without connector
            // would be unreachable outside this JVM
            cs = JMXConnectorServerFactory.newJMXConnectorServer(getMBeanServerURL(), null, mBeanServer);
            cs.start();

        }
        return mBeanServer;
    } catch (Exception ex) {
        throw new PogamutException("Error during JMX initialization.", ex);
    }
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:32,代碼來源:DefaultPogamutPlatform.java

示例4: 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

示例5: createServerSide

import javax.management.remote.JMXConnectorServerFactory; //導入依賴的package包/類
private JMXServiceURL createServerSide(Map<String, Object> serverMap)
throws Exception {
    final int NINETY_SECONDS = 90;

    System.out.println("SecurityTest::createServerSide: Start") ;

    // Prepare server side security env
    HashMap<String, Object> env = setServerSecurityEnv(serverMap);

    // Create and start mbean server and connector server
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    JMXServiceURL url = new JMXServiceURL("rmi", null, 0);
    cs = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
    cs.start();

    // Waits availibility of connector server
    Utils.waitReady(cs, NINETY_SECONDS);

    JMXServiceURL addr = cs.getAddress();

    System.out.println("SecurityTest::createServerSide: Done.") ;

    return addr;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:25,代碼來源:SecurityTest.java

示例6: 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:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:ListenerScaleTest.java

示例7: 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:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:RMIConnectorLogAttributesTest.java

示例8: 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

示例9: 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

示例10: main

import javax.management.remote.JMXConnectorServerFactory; //導入依賴的package包/類
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);
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:17,代碼來源:Server.java

示例11: main

import javax.management.remote.JMXConnectorServerFactory; //導入依賴的package包/類
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");
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:21,代碼來源:Server.java

示例12: main

import javax.management.remote.JMXConnectorServerFactory; //導入依賴的package包/類
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");
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:25,代碼來源:Server.java

示例13: registerInstrumentationStats

import javax.management.remote.JMXConnectorServerFactory; //導入依賴的package包/類
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();
    }
}
 
開發者ID:Cojac,項目名稱:Cojac,代碼行數:24,代碼來源:CojacReferences.java

示例14: startRMIConnector

import javax.management.remote.JMXConnectorServerFactory; //導入依賴的package包/類
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);
  }
}
 
開發者ID:iisi-nj,項目名稱:GemFireLite,代碼行數:26,代碼來源:GemliteAgent.java

示例15: initConnectorServer

import javax.management.remote.JMXConnectorServerFactory; //導入依賴的package包/類
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;
    }
}
 
開發者ID:toyboxman,項目名稱:yummy-xml-UI,代碼行數:19,代碼來源:Numen.java


注:本文中的javax.management.remote.JMXConnectorServerFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。