简体   繁体   English

确定我们的应用程序部署到哪个Application Server?

[英]Determine Which Application Server our application is deployed to?

Our J2EE Application is deployed to JBoss and sometimes to OC4J . 我们的J2EE应用程序部署到JBoss,有时部署到OC4J。 Can I know which one is being used? 我可以知道正在使用哪一个吗? I hope there is a method returning the container information on runtime. 我希望有一个方法在运行时返回容器信息。

Simplest thing I can think of is to look through the system properties at runtime, since both servers are almost certainly going to define their own. 我能想到的最简单的事情是在运行时查看系统属性,因为两个服务器几乎肯定会定义自己的。 For example, JBoss 4 defines the jboss.server.dir system property. 例如,JBoss 4定义了jboss.server.dir系统属性。 Check to see if that property exists, and if it does, then you can assume you're running under that server. 检查该属性是否存在,如果存在,则可以假设您在该服务器下运行。 OC4J will have something similar. OC4J会有类似的东西。

Alternatively, try reflectively loading a class that is part of the server's infrastructure (eg org.jboss.Version in JBoss 4). 或者,尝试反射性地加载属于服务器基础结构的类(例如JBoss 4中的org.jboss.Version )。 If it exists, you know what server you're on. 如果存在,您就知道您所在的服务器。

您可以通过ServletContext#getServerInfo()找到它。

Most likely JMX is what you are going to need to use. 最有可能JMX是您需要使用的。 Both containers likely expose details about themselves as MBeans. 两个容器都可能将自己的详细信息公开为MBean。 Here is some Oracle documentation on JMX and JBoss documentation . 以下是有关JMXJBoss文档的一些Oracle 文档

更改为System.getProperty("jboss.home.dir")

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

相关问题 确定已部署的Web应用程序版本 - Determine deployed web application version 如何确定正在运行应用程序的Application Server的类型? - How to determine type of Application Server an application is running on? 确定应用程序正在应用程序服务器下运行 - Determine that application is running under application server 如何以固定的时间间隔调用Java方法,该方法作为Web应用程序部署到Apache Tomcat服务器? - How to call Java method on patricular interval of time which is deployed to Apache Tomcat server as a web application? 如何在tomcat服务器中获取所有已部署的应用程序 - How to get all deployed application in tomcat server 多个组件部署到同一应用程序服务器 - Multiple components deployed to same application server 使用tomcat服务器编辑已部署的应用程序 - Edit a deployed application using tomcat server JBoss Application Server:从另一台机器访问已部署的Web应用程序 - JBoss Application Server: Accessing deployed web application from another machine 如何将已部署的应用程序从应用程序服务器更改为Web服务器? - How can i change deployed application to webserver from application server? 如何为部署到WebSphere Application Server的应用程序创建生命周期侦听器? - How to create a lifecycle listener for an application deployed to WebSphere Application Server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM