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


Java RMIConnectorServer類代碼示例

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


RMIConnectorServer類屬於javax.management.remote.rmi包,在下文中一共展示了RMIConnectorServer類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import javax.management.remote.rmi.RMIConnectorServer; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    RMIJRMPServerImplSub impl = new RMIJRMPServerImplSub();

    System.out.println("Creating connectorServer");
    connectorServer = new RMIConnectorServer(url, null, impl, mbs);
    System.out.println("Starting connectorServer");
    connectorServer.start();
    System.out.println("Making client");
    RMIConnection cc = impl.newClient(null);
    System.out.println("Closing client");
    cc.close();
    if (connectorServer.isActive()) {
        System.out.println("Stopping connectorServer");
        connectorServer.stop();
    }
    if (failure == null)
        System.out.println("TEST PASSED, no deadlock");
    else
        System.out.println("TEST FAILED");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:ConnectorStopDeadlockTest.java

示例2: connect

import javax.management.remote.rmi.RMIConnectorServer; //導入依賴的package包/類
private void connect() throws IOException {
    System.out.println(
            "JMXConnectorThread: Attempting JMX connection on: "
                    + addr + " on port " + jmxPort);
    JMXServiceURL url;
    try {
        url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"
                + addr + ":" + jmxPort + "/jmxrmi");
    } catch (MalformedURLException e) {
        throw new RuntimeException("Test failed.", e);
    }
    Map<String, Object> env = new HashMap<>();
    if (useSSL) {
        SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory();
        env.put("com.sun.jndi.rmi.factory.socket", csf);
        env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf);
    }
    // connect and immediately close
    JMXConnector c = JMXConnectorFactory.connect(url, env);
    c.close();
    System.out.println("JMXConnectorThread: connection to JMX worked");
    jmxConnectWorked = true;
    checkRmiSocket();
    latch.countDown(); // signal we are done.
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:26,代碼來源:JMXAgentInterfaceBinding.java

示例3: init

import javax.management.remote.rmi.RMIConnectorServer; //導入依賴的package包/類
static JmxConnector init(Properties props) throws IOException {
	Integer port = Integer.decode(props.getProperty(JMXEndpoint.JMX_RMI_PORT_PROPERTY));

	if (!JmxConnectors.isPortAvailable(port))
		return null;

	String name = "com.devexperts.qd.monitoring:type=RmiServer,port=" + port;
	RMIJRMPServerImpl srvImpl = new RMIJRMPServerImpl(port, null, null, null);
	RMIConnectorServer rmiServer = new RMIConnectorServer(
		new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + port +  "/jmxrmi"),
		null, srvImpl, ManagementFactory.getPlatformMBeanServer());
	ConnectorImpl connector = new ConnectorImpl(name, rmiServer);
	if (!JmxConnectors.addConnector(port, connector))
		return null; // port is already taken

	LocateRegistry.createRegistry(port);
	connector.setRegistration(Management.registerMBean(rmiServer, null, name));
	rmiServer.start();
	QDLog.log.info("RMI management port is " + port);
	return connector;
}
 
開發者ID:Devexperts,項目名稱:QD,代碼行數:22,代碼來源:JmxRmi.java

示例4: maybeInitJmx

import javax.management.remote.rmi.RMIConnectorServer; //導入依賴的package包/類
private void maybeInitJmx()
{
    if (System.getProperty("com.sun.management.jmxremote.port") != null)
        return;

    String jmxPort = System.getProperty("cassandra.jmx.local.port");
    if (jmxPort == null)
        return;

    System.setProperty("java.rmi.server.hostname", InetAddress.getLoopbackAddress().getHostAddress());
    RMIServerSocketFactory serverFactory = new RMIServerSocketFactoryImpl();
    Map<String, ?> env = Collections.singletonMap(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, serverFactory);
    try
    {
        LocateRegistry.createRegistry(Integer.valueOf(jmxPort), null, serverFactory);
        JMXServiceURL url = new JMXServiceURL(String.format("service:jmx:rmi://localhost/jndi/rmi://localhost:%s/jmxrmi", jmxPort));
        jmxServer = new RMIConnectorServer(url, env, ManagementFactory.getPlatformMBeanServer());
        jmxServer.start();
    }
    catch (IOException e)
    {
        exitOrFail(1, e.getMessage(), e.getCause());
    }
}
 
開發者ID:scylladb,項目名稱:scylla-tools-java,代碼行數:25,代碼來源:CassandraDaemon.java

示例5: newJMXConnectorServer

import javax.management.remote.rmi.RMIConnectorServer; //導入依賴的package包/類
public JMXConnectorServer newJMXConnectorServer(JMXServiceURL serviceURL,
                                                Map<String,?> environment,
                                                MBeanServer mbeanServer)
        throws IOException {
    if (!serviceURL.getProtocol().equals("rmi")) {
        throw new MalformedURLException("Protocol not rmi: " +
                                        serviceURL.getProtocol());
    }
    return new RMIConnectorServer(serviceURL, environment, mbeanServer);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:ServerProvider.java

示例6: newJMXConnectorServer

import javax.management.remote.rmi.RMIConnectorServer; //導入依賴的package包/類
public JMXConnectorServer newJMXConnectorServer(JMXServiceURL serviceURL,
                                                Map<String,?> environment,
                                                MBeanServer mbeanServer)
        throws IOException {
    if (!serviceURL.getProtocol().equals("iiop")) {
        throw new MalformedURLException("Protocol not iiop: " +
                                        serviceURL.getProtocol());
    }
    return new RMIConnectorServer(serviceURL, environment, mbeanServer);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:ServerProvider.java

示例7: connect

import javax.management.remote.rmi.RMIConnectorServer; //導入依賴的package包/類
@Override
public @NotNull JMXConnector connect() throws IOException {
  final Map<String, Object> environment = environment();
  if (ssl) {
    environment.put(Context.SECURITY_PROTOCOL, "ssl");
    final SslRMIClientSocketFactory clientSocketFactory = new SslRMIClientSocketFactory();
    environment.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, clientSocketFactory);
    environment.put("com.sun.jndi.rmi.factory.socket", clientSocketFactory);
  }
  final JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + address() + "/jmxrmi");
  return JMXConnectorFactory.connect(address, environment);
}
 
開發者ID:nolequen,項目名稱:jmx-prometheus-exporter,代碼行數:13,代碼來源:RMIConnector.java

示例8: test

import javax.management.remote.rmi.RMIConnectorServer; //導入依賴的package包/類
private static boolean test(String proto, MBeanServer mbs)
        throws Exception {
    System.out.println("Testing for proto " + proto);

    JMXConnectorServer cs;
    JMXServiceURL url = new JMXServiceURL(proto, null, 0);
    try {
        cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null,
                                                             mbs);
    } catch (MalformedURLException e) {
        System.out.println("System does not recognize URL: " + url +
                           "; ignoring");
        return true;
    }
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXServiceURL rmiurl = new JMXServiceURL("rmi", null, 0);
    JMXConnector client = JMXConnectorFactory.connect(addr);
    MBeanServerConnection mbsc = client.getMBeanServerConnection();
    ObjectName on = new ObjectName("x:proto=" + proto + ",ok=yes");
    mbsc.createMBean(RMIConnectorServer.class.getName(),
                     on,
                     mletName,
                     new Object[] {rmiurl, null},
                     new String[] {JMXServiceURL.class.getName(),
                                   Map.class.getName()});
    System.out.println("Successfully deserialized with " + proto);
    mbsc.unregisterMBean(on);

    client.close();
    cs.stop();
    return true;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:34,代碼來源:TargetMBeanTest.java

示例9: newJMXConnectorServer

import javax.management.remote.rmi.RMIConnectorServer; //導入依賴的package包/類
public JMXConnectorServer newJMXConnectorServer(JMXServiceURL url,
                                                Map<String,?> map,
                                                MBeanServer mbeanServer)
    throws IOException {
    final String protocol = url.getProtocol();
    called = true;
    System.out.println("JMXConnectorServerProviderImpl called");
    if(protocol.equals("rmi"))
        return new RMIConnectorServer(url, map, mbeanServer);
    if(protocol.equals("throw-provider-exception"))
        throw new JMXProviderException("I have been asked to throw");

    throw new IllegalArgumentException("UNKNOWN PROTOCOL");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:15,代碼來源:JMXConnectorServerProviderImpl.java

示例10: createJMXConnector

import javax.management.remote.rmi.RMIConnectorServer; //導入依賴的package包/類
private JMXConnector createJMXConnector() throws Exception {
  JMXServiceURL url = new JMXServiceURL(this.urlString);
  RMIServerSocketFactory ssf = new MX4JServerSocketFactory(
      true, true, "any", "any", new LocalLogWriter(LogWriterImpl.FINE_LEVEL), new Properties());
  RMIClientSocketFactory csf = new SslRMIClientSocketFactory();
  
  Map env = new HashMap();
  env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, ssf);
  env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf);
    
  return JMXConnectorFactory.connect(url, env);
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:13,代碼來源:AdminDUnitTestCase.java


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