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

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

问题描述

我们的 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.

或者,尝试反射加载属于服务器基础结构一部分的类(例如 JBoss 4 中的 org.jboss.Version).如果存在,您就知道自己在哪个服务器上.

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.

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

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