如何编程获得weblogic的servername、ListenAddress 、port、version
参考get-the-name-of-the-server-in-which-i-am-receiving-requests-to-my-app-on-weblogi
try
{
InitialContext ctx = new InitialContext();
String serverName = System.getProperty("weblogic.Name");
MBeanServer server = (MBeanServer)ctx.lookup("java:comp/env/jmx/runtime");
ObjectName objName = new ObjectName("com.bea:Name=" + serverName + ",Type=ServerRuntime");
Integer port = (Integer)server.getAttribute(objName, "ListenPort");
String ListenAddress = (String)server.getAttribute(objName, "ListenAddress");
String WeblogicVersion = (String)server.getAttribute(objName, "WeblogicVersion");
System.out.println("Server Name : " + serverName + "Listen Address : " + ListenAddress + " PORT : " +
port + " WeblogicVersion : " + WeblogicVersion);
}
catch(Exception e)
{
//
}
评论
发表评论