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;
}
}
java类javax.management.remote.JMXConnectorServer的实例源码
Numen.java 文件源码
项目:yummy-xml-UI
阅读 16
收藏 0
点赞 0
评论 0
Agent.java 文件源码
项目:infobip-open-jdk-8
阅读 31
收藏 0
点赞 0
评论 0
private static synchronized void startLocalManagementAgent() {
Properties agentProps = VMSupport.getAgentProperties();
// start local connector if not started
if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
String address = cs.getAddress().toString();
// Add the local connector address to the agent properties
agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);
try {
// export the address to the instrumentation buffer
ConnectorAddressLink.export(address);
} catch (Exception x) {
// Connector server started but unable to export address
// to instrumentation buffer - non-fatal error.
warning(EXPORT_ADDRESS_FAILED, x.getMessage());
}
}
}
ListenerScaleTest.java 文件源码
项目:infobip-open-jdk-8
阅读 22
收藏 0
点赞 0
评论 0
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();
}
}
ProviderTest.java 文件源码
项目:infobip-open-jdk-8
阅读 25
收藏 0
点赞 0
评论 0
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());
}
Agent.java 文件源码
项目:jdk8u-dev-jdk
阅读 28
收藏 0
点赞 0
评论 0
private static synchronized void startLocalManagementAgent() {
Properties agentProps = VMSupport.getAgentProperties();
// start local connector if not started
if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
String address = cs.getAddress().toString();
// Add the local connector address to the agent properties
agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);
try {
// export the address to the instrumentation buffer
ConnectorAddressLink.export(address);
} catch (Exception x) {
// Connector server started but unable to export address
// to instrumentation buffer - non-fatal error.
warning(EXPORT_ADDRESS_FAILED, x.getMessage());
}
}
}
ListenerScaleTest.java 文件源码
项目:jdk8u-dev-jdk
阅读 24
收藏 0
点赞 0
评论 0
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();
}
}
ProviderTest.java 文件源码
项目:jdk8u-dev-jdk
阅读 23
收藏 0
点赞 0
评论 0
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());
}
ListenerScaleTest.java 文件源码
项目:jdk7-jdk
阅读 25
收藏 0
点赞 0
评论 0
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();
}
}
IIOPURLTest.java 文件源码
项目:jdk7-jdk
阅读 23
收藏 0
点赞 0
评论 0
public static void main(String[] args) throws Exception {
JMXServiceURL inputAddr =
new JMXServiceURL("service:jmx:iiop://");
JMXConnectorServer s =
JMXConnectorServerFactory.newJMXConnectorServer(inputAddr, null,
null);
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
mbs.registerMBean(s, new ObjectName("a:b=c"));
s.start();
JMXServiceURL outputAddr = s.getAddress();
if (!outputAddr.getURLPath().startsWith("/ior/IOR:")) {
System.out.println("URL path should start with \"/ior/IOR:\": " +
outputAddr);
System.exit(1);
}
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();
}
ConnectorBootstrap.java 文件源码
项目:openjdk-source-code-learn
阅读 20
收藏 0
点赞 0
评论 0
/**
* Initializes and starts the JMX Connector Server.
* If the com.sun.management.jmxremote.port property is not defined,
* simply return. Otherwise, attempts to load the config file, and
* then calls {@link #initialize(java.lang.String, java.util.Properties)}.
*
**/
public static synchronized JMXConnectorServer initialize() {
// Load a new management properties
final Properties props = Agent.loadManagementProperties();
if (props == null) {
return null;
}
final String portStr = props.getProperty(PropertyNames.PORT);
// System.out.println("initializing: {port=" + portStr + ",
// properties="+props+"}");
return initialize(portStr, props);
}