1 5 package org.exoplatform.commons; 6 7 8 public class Environment { 9 10 static final public int UNKNOWN = 0 ; 11 static final public int STAND_ALONE = 1 ; 12 static final public int TOMCAT_PLATFORM = 2 ; 13 static final public int JBOSS_PLATFORM = 3 ; 14 static final public int JETTY_PLATFORM = 4 ; 15 static final public int WEBSHPERE_PLATFORM = 5; 16 static final public int WEBLOGIC_PLATFORM = 6; 17 18 static private Environment singleton_ ; 19 20 private int platform_ ; 21 22 private Environment() { 23 String catalinaHome = System.getProperty("catalina.home"); 24 String jbossHome = System.getProperty("jboss.home.dir"); 25 String jettyHome = System.getProperty("jetty.home"); 26 String websphereHome = System.getProperty("was.install.root"); 27 String weblogicHome = System.getProperty("weblogic.Name"); 28 String standAlone = System.getProperty("maven.exoplatform.dir") ; 29 if (jbossHome != null) { 30 platform_ = JBOSS_PLATFORM; 31 } else if (catalinaHome != null) { 32 platform_ = TOMCAT_PLATFORM ; 33 } else if (jettyHome != null) { 34 platform_ = JETTY_PLATFORM ; 35 } else if (websphereHome != null) { 36 platform_ = WEBSHPERE_PLATFORM ; 37 } else if (weblogicHome != null) { 38 platform_ = WEBLOGIC_PLATFORM ; 39 }else if (standAlone != null) { 40 platform_ = STAND_ALONE ; 41 } else { 42 platform_ = UNKNOWN ; 43 } 44 } 45 46 public int getPlatform() { return platform_ ; } 47 48 static public Environment getInstance() { 49 if (singleton_ == null) { 50 synchronized (Environment.class) { 51 singleton_ = new Environment() ; 52 } 53 } 54 return singleton_ ; 55 } 56 } | Popular Tags |