How to determine type of Application Server an application is running on?

﹥>﹥吖頭↗ 提交于 2019-12-23 17:14:46

问题


Our EJB3 application can run on top of Oracle AS or JBoss AS. Is there a way to find out type of AS during runtime?


回答1:


You can check the concrete type of object at runtime using reflection, e.g. the EJBContext that is injected by the app. server.




回答2:


Another way is to check for an app-server specific value in System properties.

// EXAMPLE:
if (System.getProperty("catalina.base") != null) {
  // Using Tomcat
  ...
else if (System.getProperty("jboss.server.name") != null) {
  // Using JBoss
  ...
else if (System.getProperty("was.install.root") != null) {
  // Using WebSphere
  ...


来源:https://stackoverflow.com/questions/2244891/how-to-determine-type-of-application-server-an-application-is-running-on

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!