本文整理汇总了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());
}
示例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();
}
}
示例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);
}
示例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();
}
}
示例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;
}
示例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();
}
示例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);
}
}
示例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();
}
}
示例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();
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}