本文整理匯總了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");
}
示例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.
}
示例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;
}
示例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());
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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");
}
示例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);
}