[lsc-changes] r298 - lsc/trunk/src/main/java/org/lsc

jclarke at lsc-project.org jclarke at lsc-project.org
Mon Jul 20 12:26:38 CEST 2009


Author: jclarke
Date: 2009-07-20 12:26:38 +0200 (Mon, 20 Jul 2009)
New Revision: 298

Modified:
   lsc/trunk/src/main/java/org/lsc/Configuration.java
   lsc/trunk/src/main/java/org/lsc/Launcher.java
Log:
Applying commit #297 to trunk.

Modified: lsc/trunk/src/main/java/org/lsc/Configuration.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/Configuration.java	2009-07-20 10:24:52 UTC (rev 297)
+++ lsc/trunk/src/main/java/org/lsc/Configuration.java	2009-07-20 10:26:38 UTC (rev 298)
@@ -273,9 +273,8 @@
 	}
 	
 	private static String appendDirSeparator(String path) {
-		String seperator = System.getProperty("file.separator");
-		if (!path.endsWith(seperator)) {
-			return path + seperator;
+		if (!path.endsWith(getSeparator())) {
+			return path + getSeparator();
 		}
 		return path;
 	}
@@ -318,7 +317,6 @@
 				throw new ExceptionInInitializerError(errorMessage);
 			}
 		}
-		LOGGER.debug("Configuration directory is " + ret);
 		return ret;
 	}
 	
@@ -394,7 +392,7 @@
 	 *            the url of the configuration file to load
 	 */
 	static void setConfiguration(URL url) throws ConfigurationException {
-		LOGGER.debug("Loading configuration url : " + url);
+		LOGGER.debug("Loading configuration url: " + url);
 		config = new PropertiesConfiguration(url);
 		config.getKeys();
 	}
@@ -406,7 +404,7 @@
 	 *            the url of the configuration file to load
 	 */
 	static void addConfiguration(URL url) throws ConfigurationException {
-		LOGGER.debug("Adding configuration : " + url);
+		LOGGER.debug("Adding configuration: " + url);
 		PropertiesConfiguration configTmp = new PropertiesConfiguration(url);
 		Iterator<?> configKeys = configTmp.getKeys();
 		while (configKeys.hasNext()) {
@@ -464,4 +462,8 @@
 	public static Properties getPropertiesFromFileInConfigDir(String fileName) throws FileNotFoundException, IOException {
 		return getPropertiesFromFile(Configuration.getConfigurationDirectory() + fileName);
 	}
+
+	public static String getSeparator() {
+		return System.getProperty("file.separator");
+	}
 }

Modified: lsc/trunk/src/main/java/org/lsc/Launcher.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/Launcher.java	2009-07-20 10:24:52 UTC (rev 297)
+++ lsc/trunk/src/main/java/org/lsc/Launcher.java	2009-07-20 10:26:38 UTC (rev 298)
@@ -47,6 +47,7 @@
 
 import java.io.File;
 import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
@@ -57,6 +58,7 @@
 import org.apache.commons.cli.HelpFormatter;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
+import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 
@@ -116,16 +118,25 @@
      */
     public void run() {
         try {
-        	/* if a configuration directory was set on command line, save it to Configuration */
+        	// if a configuration directory was set on command line, save it to Configuration
         	if(configurationLocation != null) {
         		Configuration.setLocation(configurationLocation);
         	}
+        	        	
+        	// setup LOG4J
+        	// first, reset the configuration because LOG4J automatically loads it from properties
+        	// while this may be the Java way, it's not our way, we like real text files, not JARs.
+        	LogManager.resetConfiguration();
+
+        	String log4jPropertiesFile = Configuration.getConfigurationDirectory() + "log4j.properties";
+        	PropertyConfigurator.configure(log4jPropertiesFile);
         	
-        	/* load LOG4J properties */
-        	PropertyConfigurator.configure(new File(Configuration.getConfigurationDirectory(), "log4j.properties").toURI().toURL());
+        	// WARNING: don't log anything before HERE!
         	
-        	/* do the work! */
-            sync.launch(syncType, cleanType);
+    		LOGGER.debug("Reading configuration from " + Configuration.getConfigurationDirectory());
+        	
+        	// do the work!
+    		sync.launch(syncType, cleanType);
         } catch (Exception e) {
             LOGGER.error(e, e);
         }



More information about the lsc-changes mailing list