equal
deleted
inserted
replaced
30 import sun.management.jdp.JdpException; |
30 import sun.management.jdp.JdpException; |
31 import sun.management.jmxremote.ConnectorBootstrap; |
31 import sun.management.jmxremote.ConnectorBootstrap; |
32 |
32 |
33 import javax.management.remote.JMXConnectorServer; |
33 import javax.management.remote.JMXConnectorServer; |
34 import javax.management.remote.JMXServiceURL; |
34 import javax.management.remote.JMXServiceURL; |
35 import javax.management.remote.rest.PlatformRestAdapter; |
|
36 import java.io.*; |
35 import java.io.*; |
37 import java.lang.management.ManagementFactory; |
36 import java.lang.management.ManagementFactory; |
38 import java.lang.reflect.Method; |
37 import java.lang.reflect.Method; |
39 import java.net.InetAddress; |
38 import java.net.InetAddress; |
40 import java.net.MalformedURLException; |
39 import java.net.MalformedURLException; |
244 "com.sun.management.enableThreadContentionMonitoring"; |
243 "com.sun.management.enableThreadContentionMonitoring"; |
245 private static final String LOCAL_CONNECTOR_ADDRESS_PROP = |
244 private static final String LOCAL_CONNECTOR_ADDRESS_PROP = |
246 "com.sun.management.jmxremote.localConnectorAddress"; |
245 "com.sun.management.jmxremote.localConnectorAddress"; |
247 private static final String SNMP_AGENT_NAME = |
246 private static final String SNMP_AGENT_NAME = |
248 "SnmpAgent"; |
247 "SnmpAgent"; |
|
248 private static final String REST_ADAPTER_NAME = "RestAdapter"; |
249 |
249 |
250 private static final String JDP_DEFAULT_ADDRESS = "224.0.23.178"; |
250 private static final String JDP_DEFAULT_ADDRESS = "224.0.23.178"; |
251 private static final int JDP_DEFAULT_PORT = 7095; |
251 private static final int JDP_DEFAULT_PORT = 7095; |
252 |
252 |
253 // The only active agent allowed |
253 // The only active agent allowed |
545 } |
545 } |
546 return mgmtProps; |
546 return mgmtProps; |
547 } |
547 } |
548 |
548 |
549 private static void loadRestAdapter(Properties props) { |
549 private static void loadRestAdapter(Properties props) { |
550 try { |
550 /* |
551 if (props.get(REST_PORT) != null) { |
551 * Load the rest adapter service |
552 PlatformRestAdapter.init(props); |
552 */ |
553 System.out.println("Rest Base URL : " + PlatformRestAdapter.getBaseURL()); |
553 AgentProvider provider = AccessController.doPrivileged( |
554 } |
554 (PrivilegedAction<AgentProvider>) () -> { |
555 } catch (Throwable ex) { |
555 for (AgentProvider aProvider : ServiceLoader.loadInstalled(AgentProvider.class)) { |
556 ex.printStackTrace(); |
556 if (aProvider.getName().equals(REST_ADAPTER_NAME)) |
|
557 return aProvider; |
|
558 } |
|
559 return null; |
|
560 }, null |
|
561 ); |
|
562 |
|
563 if (provider != null) { |
|
564 provider.startAgent(props); |
|
565 } else { // Rest adapter doesn't exist - initialization fails |
|
566 throw new UnsupportedOperationException("Unsupported management property: " + REST_PORT); |
557 } |
567 } |
558 } |
568 } |
559 |
569 |
560 private static void loadSnmpAgent(Properties props) { |
570 private static void loadSnmpAgent(Properties props) { |
561 /* |
571 /* |