从webapp访问受管服务器主机名和端口

时间:2017-04-01 08:03:04

标签: java-ee weblogic jndi jmx weblogic12c

我正在处理将在Weblogic中部署的Web应用程序。在此应用程序中,我需要访问受管服务器的端口和主机。在搜索了一下后发现JMX与JNDI有助于获取服务器详细信息,但不确定是否可以通过这种方式访问​​主机和端口详细信息,在在线文档中找不到多少帮助。有人可以帮我搞清楚吗?

2 个答案:

答案 0 :(得分:2)

如果您只需要主机名(而不是服务器名),则只需:

var name = ["a",nil,"3"] if let nil_index = name.index(of: nil){ name[nil_index] = "empty" } print(name as! [String]) // Output is ["a", "empty", "3"]

答案 1 :(得分:1)

    //Get ServerConfiguration
    ctx = new InitialContext();
    MBeanServer mBeanServer = (MBeanServer) ctx.lookup("java:comp/env/jmx/runtime");
    ObjectName ServerConfiguration = (ObjectName) mBeanServer
            .getAttribute(new ObjectName(RuntimeServiceMBean.OBJECT_NAME), "ServerConfiguration");
    // Get ListenPort 
    port = mBeanServer.getAttribute(ServerConfiguration, "ListenPort").toString();