geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r580151 - in /geronimo/server/trunk: configs/jaxws-deployer/src/main/resources/ modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSToolsCLI.java
Date Thu, 27 Sep 2007 20:58:10 GMT
Author: gawor
Date: Thu Sep 27 13:58:10 2007
New Revision: 580151

URL: http://svn.apache.org/viewvc?rev=580151&view=rev
Log:
a better way to determin geronimo home

Added:
    geronimo/server/trunk/configs/jaxws-deployer/src/main/resources/
      - copied from r580141, geronimo/server/trunk/configs/client-system/src/main/resources/
Modified:
    geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSToolsCLI.java

Modified: geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSToolsCLI.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSToolsCLI.java?rev=580151&r1=580150&r2=580151&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSToolsCLI.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSToolsCLI.java
Thu Sep 27 13:58:10 2007
@@ -19,6 +19,8 @@
 
 import java.io.File;
 import java.lang.reflect.InvocationTargetException;
+import java.net.JarURLConnection;
+import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
 
@@ -39,7 +41,7 @@
             System.exit(1);
         }
 
-        String geroninoHome = System.getProperty("org.apache.geronimo.home.dir", "..");
+        String geroninoHome = getGeronimoHome();
         String repository = System.getProperty("Xorg.apache.geronimo.repository.boot.path",
"repository");
         Maven2Repository mavenRepository = new Maven2Repository((new File(geroninoHome, repository)).getCanonicalFile());
         ArrayList<ListableRepository> repositories = new ArrayList<ListableRepository>(1);
@@ -79,6 +81,31 @@
         String [] cmdArgs = new String[args.length - 1];
         System.arraycopy(args, 1, cmdArgs, 0, args.length - 1);
         return cmdArgs;
+    }
+    
+    private static String getGeronimoHome() {
+        String geronimoHome = System.getProperty("org.apache.geronimo.home.dir");
+        if (geronimoHome != null) {
+            return geronimoHome;
+        }
+        
+        // guess from the location of the jar
+        URL url = JAXWSToolsCLI.class.getClassLoader().getResource("META-INF/startup-jar");
+        if (url != null) {
+            try {
+                JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
+                url = jarConnection.getJarFileURL();
+
+                URI baseURI = new URI(url.toString()).resolve("..");
+                File dir = new File(baseURI);                
+                return dir.getAbsolutePath();
+            } catch (Exception ignored) {
+                // ignore
+            }
+        }
+        
+        // cannot determine the directory, return parent directory
+        return "..";        
     }
 
 }



Mime
View raw message