有没有办法在Tomcat中列出每个部署jar的所有连接?
我发现此代码列出了所有应用程序:
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://31.181.71.213:9999/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url);
MBeanServerConnection server = jmxc.getMBeanServerConnection();
Set<ObjectName> names = server.queryNames(new ObjectName("Catalina:type=Host,*"), null);
Set<String> hostNames = new HashSet<String>();
for (ObjectName on : names)
{
hostNames.add(on.getKeyProperty("host"));
}
for (String str : hostNames)
{
ObjectName[] webapps = (ObjectName[]) server.getAttribute(new ObjectName("Catalina:type=Host,host=" + str), "children");
for (ObjectName ob : webapps)
{
String[] appSpl = ob.getKeyProperty("name").split("//localhost");
// webappNames.add(appSpl[1]);
System.out.println("Deployed application " + appSpl[1]);
}
}
但我怎样才能列出网络连接?
答案 0 :(得分:1)