简体   繁体   English

需要从Java代码中获取将我的应用程序部署到的weblogic主机名

[英]Need to get the weblogic hostname where my application is deployed from within my java code

I have the following piece of code from where i can get the Admin server name and the port. 我有以下代码,可以从其中获取管理服务器名称和端口。

        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=Server");
        Integer port = (Integer)server.getAttribute(objName, "ListenPort");

        System.out.println("Server Name :" + serverName + " PORT :" + port);

But I also need the weblogic hostname along with the server name. 但是我还需要weblogic主机名和服务器名。 Not sure how to get that. 不确定如何获得。

It sounds like in addition, you want the "listen address": 听起来,您还想要“收听地址”:

Via Java/JMX: 通过Java / JMX:

String listenAddress=(String)server.getAttribute(objName,"ListenAddress");

Via WLST script: 通过WLST脚本:

cd('Servers/' + serverName) 
listenAddress=str(get('ListenAddress')) 
print "Listen Address is: " , listenAddress

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从部署在 weblogic 中的 EJB java 应用程序获取 remoteHost 名称 - How to get remoteHost name from EJB java application which is deployed in weblogic 我部署的servlet在哪里? (dotcloud,java) - Where is my deployed servlet? (dotcloud, java) 我的Web应用程序部署在哪里(从Eclipse到Tomcat 7) - Where is my webapp deployed(From Eclipse to Tomcat 7) 如何协调部署到WebLogic群集中多个服务器的单个ejb计时器? - How can I coordinate a single ejb timer deployed to multiple servers within my WebLogic cluster? 在 Java 套接字编程中哪里可以找到我的服务器的主机名 - Where can I find the hostname of my server in Java Socket Programming 如何从我的Java应用程序中与C控制台应用程序进行交互 - How to interact with a C console application from within my Java application 我需要一个java方法,可以从我的API中的任何地方访问,但无法使用API​​从应用程序访问 - I need to have a java method that can be accessed from anywhere within my API but cannot be accessed from the application using the API 需要我的Java代码的帮助 - Need help of my java code 需要固定我的Java代码 - Need to fasten my Java code 如何以编程方式从我的Java应用程序中获取内存,线程和CPU用法? - How can I programmatically get memory, thread and CPU usuage from within my Java application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM