User: oberg   
  Date: 01/02/20 07:29:01

  Modified:    tomcat/src/main/org/jboss/tomcat TomcatEntry.java
  Log:
  Added autodetection of tomcat.home property
  
  Revision  Changes    Path
  1.2       +15 -5     contrib/tomcat/src/main/org/jboss/tomcat/TomcatEntry.java
  
  Index: TomcatEntry.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/contrib/tomcat/src/main/org/jboss/tomcat/TomcatEntry.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TomcatEntry.java  2001/02/10 05:58:07     1.1
  +++ TomcatEntry.java  2001/02/20 15:29:00     1.2
  @@ -1,3 +1,4 @@
  +
   /*
    * JBoss, the OpenSource EJB server
    *
  @@ -269,14 +270,23 @@
       File getConfigFile(ContextManager cm) {
        // If configFile is already set, use it
        if (configFile != null)
  -         return (new File(configFile));
  +     {
  +      return new File(configFile);
  +   }
   
        // Use the "tomcat.home" property to resolve the default filename
        String tchome = System.getProperty("tomcat.home");
  -     if (tchome == null) {
  -         System.out.println(sm.getString("tomcat.nohome"));
  -         tchome = ".";
  -         // Assume current working directory
  +     if (tchome == null) 
  +   {
  +        // Find Tomcat library path (<tomcat home>/lib)
  +      // Find an arbitraty class in a JAR in /lib and use it as locator
  +        String libPath = 
org.apache.tomcat.startup.HostConfig.class.getProtectionDomain().getCodeSource().getLocation().getFile();
  +        File path = new File(libPath);
  +      
  +      // Get Tomcat home directory
  +        path = path.getParentFile().getParentFile();
  +      tchome = path.toString();
  +      System.setProperty("tomcat.home", tchome);
        }
        // Home will be identical to tomcat home if default config is used.
        cm.setInstallDir(tchome);
  
  
  

Reply via email to