Determine Which Application Server our application is deployed to?

前端 未结 4 422
别那么骄傲
别那么骄傲 2021-01-19 10:08

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 runt

4条回答
  •  情歌与酒
    2021-01-19 10:53

    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.

    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.

提交回复
热议问题