geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/serverinfo ServerInfo.java
Date Fri, 13 Feb 2004 23:21:39 GMT
dain        2004/02/13 15:21:39

  Modified:    modules/system/src/java/org/apache/geronimo/system/serverinfo
                        ServerInfo.java
  Log:
  Addded automatic detection of base directory.
  
  Revision  Changes    Path
  1.2       +18 -3     incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java
  
  Index: ServerInfo.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServerInfo.java	12 Feb 2004 18:12:52 -0000	1.1
  +++ ServerInfo.java	13 Feb 2004 23:21:39 -0000	1.2
  @@ -58,6 +58,8 @@
   import java.io.File;
   import java.net.URI;
   import java.net.URISyntaxException;
  +import java.net.JarURLConnection;
  +import java.net.URL;
   
   import org.apache.geronimo.gbean.GAttributeInfo;
   import org.apache.geronimo.gbean.GBeanInfo;
  @@ -78,7 +80,7 @@
           baseURI = null;
       }
   
  -    public ServerInfo(String baseDirectory) {
  +    public ServerInfo(String baseDirectory) throws Exception {
           // force load of server constants
           ServerConstants.getVersion();
   
  @@ -94,8 +96,21 @@
                   this.baseDirectory = baseDirectory;
               } else {
                   // last chance - guess where the base directory shoul be
  -                throw new IllegalArgumentException("Could not find base directory. Please
use the -Dgeronimo.base.dir=<your-directory> command line option.");
  +                URL url = getClass().getClassLoader().getResource("META-INF/startup-jar");
  +                if(url != null) {
  +                    try {
  +                        JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
  +                        URI uri = new URI(jarConnection.getJarFileURL().toString()).resolve("..");
  +                        this.baseDirectory = uri.getPath();
  +                    } catch (Exception e) {
  +                        // ignore exception is thrown below
  +                    }
  +                }
               }
  +        }
  +
  +        if(this.baseDirectory == null) {
  +            throw new IllegalArgumentException("Could not find base directory. Please use
the -Dgeronimo.base.dir=<your-directory> command line option.");
           }
   
           // now that we have the base directory, check that it is a valid directory
  
  
  

Mime
View raw message