unicorn commit: fixed unicorn.home resolve

changeset:   1282:e5d1ea30707f
user:        Thomas Gambet <tgambet@w3.org>
date:        Mon Jun 21 11:22:52 2010 -0400
files:       src/org/w3c/unicorn/Framework.java
description:
fixed unicorn.home resolve


diff -r 4516829792be -r e5d1ea30707f src/org/w3c/unicorn/Framework.java
--- a/src/org/w3c/unicorn/Framework.java	Mon Jun 21 10:45:25 2010 -0400
+++ b/src/org/w3c/unicorn/Framework.java	Mon Jun 21 11:22:52 2010 -0400
@@ -13,6 +13,7 @@
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -132,13 +133,14 @@
 	public static void initCore() throws InitializationFailedException {
 		if (System.getProperty("unicorn.home") == null) {
 			try {
-				URL classesDir = Framework.class.getResource("/");
-				File classes = new File(classesDir.toURI());
-				File webInf = new File(classes.getParent());
-				System.setProperty("unicorn.home", webInf.getParent());
+				URL frameworkDir = Framework.class.getResource("Framework.class");
+				File unicornHome = new File(frameworkDir.toURI());
+				for (int i=0; i<6; i++)
+					unicornHome = unicornHome.getParentFile();
+				System.setProperty("unicorn.home", unicornHome.getAbsolutePath());
 			} catch (URISyntaxException e) {
 				throw new InitializationFailedException(e.getMessage(), e);
-			}
+			} 
 		}
 		
 		// Log4j initialization attempt

Received on Monday, 21 June 2010 15:25:33 UTC