确定我们的应用程序部署到哪个Application Server? [英] Determine Which Application Server our application is deployed to?

查看:129
本文介绍了确定我们的应用程序部署到哪个Application Server?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的J2EE应用程序部署到JBoss,有时部署到OC4J。
我可以知道正在使用哪一个?
我希望有一个方法在运行时返回容器信息。

Our J2EE Application is deployed to JBoss and sometimes to OC4J . Can I know which one is being used? I hope there is a method returning the container information on runtime.

推荐答案

我能想到的最简单的事情是在运行时查看系统属性,因为两个服务器几乎肯定会定义自己的。例如,JBoss 4定义了 jboss.server.dir 系统属性。检查该属性是否存在,如果存在,那么您可以假设您在该服务器下运行。 OC4J会有类似的东西。

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. 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.

或者,尝试反思性地加载属于服务器基础结构的类(例如 org.jboss.Version 4)。如果它存在,你知道你在服务器上。

Alternatively, try reflectively loading a class that is part of the server's infrastructure (e.g. org.jboss.Version in JBoss 4). If it exists, you know what server you're on.

这篇关于确定我们的应用程序部署到哪个Application Server?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆