问题
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