讨论区 » AAS-V10企业版 »
v10通过代码获取http端口例子
应用可以通过jmx服务获取v10的http端口,以下为获取端口的代码片段:
Map<String, Object> environment = new HashMap<>(); String serviceURL = "service:jmx:rmi://localhost:6886/jndi/rmi://localhost:6886/jmxrmi"; environment.put(JMXConnector.CREDENTIALS, new String[]{"admin","Admin1234"}); JMXConnector jmxc = null; try { jmxc = JMXConnectorFactory.connect(new JMXServiceURL(serviceURL), environment); MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); Object obj = mbsc.getAttribute(new ObjectName("amx:pp=/domain/configs/config[server-config]/network-config/network-listeners,type=network-listener,name=http-listener-1"), "Port"); return obj.toString(); } catch (Exception e) { e.printStackTrace(); }
ps:不仅可以获取端口,还可以获取其它的服务器指标,具体参数请参考 【文档】目录里的 《V10企业版通用JMX手册》
关键字: 动态获取端口,port,jmx