KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > commons > Environment


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

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 JavaDoc catalinaHome = System.getProperty("catalina.home");
24     String JavaDoc jbossHome = System.getProperty("jboss.home.dir");
25     String JavaDoc jettyHome = System.getProperty("jetty.home");
26     String JavaDoc websphereHome = System.getProperty("was.install.root");
27     String JavaDoc weblogicHome = System.getProperty("weblogic.Name");
28     String JavaDoc 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