empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1067788 - in /incubator/empire-db/trunk: ./ empire-db-codegen/src/main/java/org/apache/empire/db/codegen/ empire-db-codegen/src/test/java/org/apache/empire/db/codegen/ empire-db-examples/empire-db-example-advanced/ empire-db-examples/empir...
Date Sun, 06 Feb 2011 22:22:58 GMT
Author: doebele
Date: Sun Feb  6 22:22:57 2011
New Revision: 1067788

URL: http://svn.apache.org/viewvc?rev=1067788&view=rev
Log:
EMPIREDB-38

Removed:
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/log4j.properties
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/log4j.properties
Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/pom.xml
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvConfig.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/pom.xml
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleConfig.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/src/main/java/org/apache/empire/samples/cxf/wssample/server/SampleConfig.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/SampleConfig.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/SampleConfig.java
    incubator/empire-db/trunk/empire-db/pom.xml
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java
    incubator/empire-db/trunk/pom.xml

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java
Sun Feb  6 22:22:57 2011
@@ -179,7 +179,7 @@ public class CodeGenConfig extends XMLCo
 	
 	/**
 	 * if TRUE record classes should have a getter and setter for each field.<br/>
-	 * Otherwiese getters / setters are omitted.
+	 * Otherwise getters / setters are omitted.
 	 */
 	private boolean createRecordProperties;
 
@@ -189,11 +189,11 @@ public class CodeGenConfig extends XMLCo
 	 * @param filename
 	 *            the file to read
 	 * 
-	 * @return true on succes
+	 * @return true on success
 	 */
 	public boolean init(String filename) {
 		// Read the properties file
-		if (super.init(filename, false, true) == false)
+		if (super.init(filename, false) == false)
 			return false;
 		// Done
 		if (readProperties(this, "properties") == false)

Modified: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java
Sun Feb  6 22:22:57 2011
@@ -40,7 +40,7 @@ public class CodeGenTest
     public void testCodeGen()
     {
         CodeGenConfig config = new CodeGenConfig();
-        config.init("testconfig.xml", true, false);
+        config.init("testconfig.xml", true);
         CodeGenWriter codeGen = new CodeGenWriter(config);
         
         DBDatabase db = new DBDatabase()

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml Sun
Feb  6 22:22:57 2011
@@ -93,5 +93,61 @@
 		<jdbcPwd>empire-db</jdbcPwd>
 		<schemaName>DBSAMPLEADV</schemaName>
 	</properties-sqlserver>
+
+	<!-- log4j configuration node -->
+	<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+		<appender name="default" class="org.apache.log4j.ConsoleAppender">
+			<!-- layout class="org.apache.log4j.TTCCLayout"/ -->
+			<layout class="org.apache.log4j.PatternLayout">
+				<!-- param name="ConversionPattern" value="NSB(%c) %-5p %m	at %l%n"/ -->
+				<param name="ConversionPattern" value="%-5p [%d{yyyy/MM/dd HH:mm}]: %m		at %l %n"/>
+			</layout>
+		</appender>
+	
+		<!-- log detail configuration -->
+
+		<logger name="org.apache.empire.xml" additivity="false">
+			<level value="info"/>
+			<appender-ref ref="default"/>
+		</logger>
+		
+		<logger name="org.apache.empire.commons" additivity="false">
+			<level value="warn"/>
+			<appender-ref ref="default"/>
+		</logger>
+	
+		<logger name="org.apache.empire.db" additivity="false">
+			<level value="warn"/>
+			<appender-ref ref="default"/>
+		</logger>
+
+		<!-- Set this level to "debug" to log all SQL-Statements -->		
+		<logger name="org.apache.empire.db.DBDatabase" additivity="false">
+			<level value="debug"/>
+			<appender-ref ref="default"/>
+		</logger>
+		<logger name="org.apache.empire.db.DBDatabaseDriver" additivity="false">
+			<level value="debug"/>
+			<appender-ref ref="default"/>
+		</logger>
+
+		<!-- Set this level to "debug" to log all DDL-Statements -->		
+		<logger name="org.apache.empire.db.DBSQLScript" additivity="false">
+			<level value="debug"/>
+			<appender-ref ref="default"/>
+		</logger>
+		
+		<logger name="org.apache.empire.samples.db.advanced" additivity="false">
+			<level value="debug"/>
+			<appender-ref ref="default"/>
+		</logger>
+	
+		<root>
+			<priority value="info"/>
+			<appender-ref ref="default"/>
+		</root>
+
+	</log4j:configuration>
 	
 </config>

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/pom.xml?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/pom.xml (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/pom.xml Sun Feb
 6 22:22:57 2011
@@ -30,6 +30,11 @@
 			<groupId>org.apache.empire-db</groupId>
 			<artifactId>empire-db</artifactId>
 		</dependency>
+		<!-- use log4j for logging -->
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-log4j12</artifactId>
+		</dependency>
 		<!-- This dependency should be declared as runtime but the exec plugin is broken atm...
-->
 		<dependency>
 		    <groupId>hsqldb</groupId>

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
Sun Feb  6 22:22:57 2011
@@ -22,7 +22,6 @@ import java.sql.Connection;
 import java.sql.DriverManager;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.logging.Logger;
 
 import org.apache.empire.commons.DateUtils;
 import org.apache.empire.commons.ErrorObject;
@@ -46,11 +45,14 @@ import org.apache.empire.db.mysql.DBData
 import org.apache.empire.db.oracle.DBDatabaseDriverOracle;
 import org.apache.empire.db.postgresql.DBDatabaseDriverPostgreSQL;
 import org.apache.empire.db.sqlserver.DBDatabaseDriverMSSQL;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class SampleAdvApp 
 {
-    private static final Logger logger = Logger.getLogger(SampleAdvApp.class.getName());
+    // Logger
+    private static final Logger log = LoggerFactory.getLogger(SampleAdvApp.class);
 
     private static final SampleAdvDB db = new SampleAdvDB();
 
@@ -184,7 +186,7 @@ public class SampleAdvApp 
             System.out.println("--------------------------------------------------------");
             System.out.println("*** ddlSample: shows how to add a column at runtime and update
a record with the added column ***");
             if (db.getDriver() instanceof DBDatabaseDriverH2) {
-            	logger.info("As H2 does not support changing a table with a view defined we
remove the view");
+            	log.info("As H2 does not support changing a table with a view defined we remove
the view");
             	System.out.println("*** drop EMPLOYEE_INFO_VIEW ***");
             	DBSQLScript script = new DBSQLScript();
             	db.getDriver().getDDLScript(DBCmdType.DROP, db.V_EMPLOYEE_INFO, script);
@@ -192,7 +194,7 @@ public class SampleAdvApp 
             }
             ddlSample(conn, idEmp2);
             if (db.getDriver() instanceof DBDatabaseDriverH2) {
-            	logger.info("And put back the view");
+            	log.info("And put back the view");
             	System.out.println("*** create EMPLOYEE_INFO_VIEW ***");
             	DBSQLScript script = new DBSQLScript();
             	db.getDriver().getDDLScript(DBCmdType.CREATE, db.V_EMPLOYEE_INFO, script);
@@ -223,22 +225,22 @@ public class SampleAdvApp 
     {
         // Establish a new database connection
         Connection conn = null;
-        logger.info("Connecting to Database'" + config.getJdbcURL() + "' / User=" + config.getJdbcUser());
+        log.info("Connecting to Database'" + config.getJdbcURL() + "' / User=" + config.getJdbcUser());
         try
         {
             // Connect to the database
             Class.forName(config.getJdbcClass()).newInstance();
             conn = DriverManager.getConnection(config.getJdbcURL(), config.getJdbcUser(),
config.getJdbcPwd());
-            logger.info("Connected successfully");
+            log.info("Connected successfully");
             // set the AutoCommit to false this session. You must commit
             // explicitly now
             conn.setAutoCommit(false);
-            logger.info("AutoCommit is " + conn.getAutoCommit());
+            log.info("AutoCommit is " + conn.getAutoCommit());
 
         } catch (Exception e)
         {
-            logger.severe("Failed to connect directly to '" + config.getJdbcURL() + "' /
User=" + config.getJdbcUser());
-            logger.severe(e.toString());
+            log.error("Failed to connect directly to '" + config.getJdbcURL() + "' / User="
+ config.getJdbcUser());
+            log.error(e.toString());
             throw new RuntimeException(e);
         }
         return conn;
@@ -372,7 +374,7 @@ public class SampleAdvApp 
         rec.setValue(T_DEP.C_BUSINESS_UNIT, businessUnit);
         if (!rec.update(conn))
         {
-            logger.severe(rec.getErrorMessage());
+            log.error(rec.getErrorMessage());
             return 0;
         }
         // Return Department ID
@@ -394,7 +396,7 @@ public class SampleAdvApp 
         rec.setValue(T_EMP.C_GENDER, gender);
         if (!rec.update(conn))
         {
-            logger.severe(rec.getErrorMessage());
+            log.error(rec.getErrorMessage());
             return 0;
         }
         // Return Employee ID
@@ -416,7 +418,7 @@ public class SampleAdvApp 
         rec.setValue(T_EDH.C_DATE_FROM, dateFrom);
         if (!rec.update(conn))
         {
-            logger.severe(rec.getErrorMessage());
+            log.error(rec.getErrorMessage());
         }
     }
 

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvConfig.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvConfig.java?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvConfig.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvConfig.java
Sun Feb  6 22:22:57 2011
@@ -18,19 +18,23 @@
  */
 package org.apache.empire.samples.db.advanced;
 
-import org.apache.commons.logging.LogFactory;
+import org.apache.empire.commons.Errors;
 import org.apache.empire.xml.XMLConfiguration;
+import org.apache.empire.xml.XMLUtil;
 import org.apache.log4j.xml.DOMConfigurator;
+import org.w3c.dom.Element;
 
 /**
  * <PRE>
  * The SampleConfig class provides access to configuration settings.
- * The configruation will be read from a xml configuration file (usually config.xml) 
+ * The configuration will be read from a xml configuration file (usually config.xml) 
  * Thus the default values here will be overridden. 
  * </PRE>
  */
 public class SampleAdvConfig extends XMLConfiguration
 {
+    // the logging configuration root node name
+    private final String loggingNodeName = "log4j:configuration";
 
     private String databaseProvider = "hsqldb";
 
@@ -49,13 +53,15 @@ public class SampleAdvConfig extends XML
      * 
      * @param filename the file to load 
      * 
-     * @return true on succes 
+     * @return true on success 
      */
     public boolean init(String filename)
     {
         // Read the properties file
-        if (super.init(filename, false, true) == false)
+        if (super.init(filename, false) == false)
             return false;
+        // Init Logging
+        initLogging();
         // Done
         if (readProperties(this, "properties")==false)
             return false;
@@ -63,6 +69,30 @@ public class SampleAdvConfig extends XML
         return readProperties(this, "properties-" + databaseProvider);
     }
 
+    /**
+     * Init logging using Log4J's DOMConfigurator 
+     * @return
+     */
+    private boolean initLogging()
+    {
+        // Get configuration root node
+        Element rootNode = getRootNode();
+        if (rootNode == null)
+            return error(Errors.ObjectNotValid, getClass().getName());
+        // Find log configuration node
+        Element loggingNode = XMLUtil.findFirstChild(rootNode, loggingNodeName);
+        if (loggingNode == null)
+        {   // log configuration node not found
+            log.error("Log configuration node {} has not been found. Logging has not been
configured.", loggingNodeName);
+            return error(Errors.ItemNotFound, loggingNodeName);
+        }
+        // Init Log4J
+        DOMConfigurator.configure(loggingNode);
+        // done
+        log.info("Logging sucessfully configured from node {}.", loggingNodeName);
+        return success();
+    }
+
     public String getDatabaseProvider()
     {
         return databaseProvider;

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml Sun Feb
 6 22:22:57 2011
@@ -93,4 +93,50 @@
 		<jdbcPwd>esteam</jdbcPwd>
 		<schemaName>DBSAMPLE</schemaName>
 	</properties-sqlserver>
+	
+	<!-- log4j configuration node -->
+	<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+		<appender name="default" class="org.apache.log4j.ConsoleAppender">
+			<!-- layout class="org.apache.log4j.TTCCLayout"/ -->
+			<layout class="org.apache.log4j.PatternLayout">
+				<!-- param name="ConversionPattern" value="NSB(%c) %-5p %m	at %l%n"/ -->
+				<param name="ConversionPattern" value="%-5p [%d{yyyy/MM/dd HH:mm}]: %m		at %l %n"/>
+			</layout>
+		</appender>
+	
+		<!-- log detail configuration -->
+		<logger name="org.apache.empire.xml" additivity="false">
+			<level value="info"/>
+			<appender-ref ref="default"/>
+		</logger>
+
+		<logger name="org.apache.empire.commons" additivity="false">
+			<level value="warn"/>
+			<appender-ref ref="default"/>
+		</logger>
+
+		<logger name="org.apache.empire.db" additivity="false">
+			<level value="warn"/>
+			<appender-ref ref="default"/>
+		</logger>
+
+		<!-- Set this level to "debug" to log all SQL-Statements -->		
+		<logger name="org.apache.empire.db.DBDatabase" additivity="false">
+			<level value="debug"/>
+			<appender-ref ref="default"/>
+		</logger>
+
+		<logger name="org.apache.empire.samples.db" additivity="false">
+			<level value="debug"/>
+			<appender-ref ref="default"/>
+		</logger>
+
+		<root>
+			<priority value="info"/>
+			<appender-ref ref="default"/>
+		</root>
+
+	</log4j:configuration>
+	
 </config>

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/pom.xml?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/pom.xml (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/pom.xml Sun Feb 
6 22:22:57 2011
@@ -30,6 +30,11 @@
 			<groupId>org.apache.empire-db</groupId>
 			<artifactId>empire-db</artifactId>
 		</dependency>
+		<!-- use log4j for logging -->
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-log4j12</artifactId>
+		</dependency>
 		<!-- This dependency should be declared as runtime but the exec plugin is broken atm...
-->
 		<dependency>
 		    <groupId>hsqldb</groupId>

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
Sun Feb  6 22:22:57 2011
@@ -21,7 +21,6 @@ package org.apache.empire.samples.db;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.util.List;
-import java.util.logging.Logger;
 
 import org.apache.empire.commons.ErrorObject;
 import org.apache.empire.db.DBColumnExpr;
@@ -38,12 +37,15 @@ import org.apache.empire.db.oracle.DBDat
 import org.apache.empire.db.postgresql.DBDatabaseDriverPostgreSQL;
 import org.apache.empire.db.sqlserver.DBDatabaseDriverMSSQL;
 import org.apache.empire.xml.XMLWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 
 
 public class SampleApp 
 {
-	private static final Logger logger = Logger.getLogger(SampleApp.class.getName());
+    // Logger
+    private static final Logger log = LoggerFactory.getLogger(SampleApp.class);
 
 	private static final SampleDB db = new SampleDB();
 
@@ -168,29 +170,29 @@ public class SampleApp 
     {
 		// Establish a new database connection
 		Connection conn = null;
-		logger.info("Connecting to Database'" + config.getJdbcURL() + "' / User=" + config.getJdbcUser());
+		log.info("Connecting to Database'" + config.getJdbcURL() + "' / User=" + config.getJdbcUser());
 		try
         {
             // Connect to the database
 			Class.forName(config.getJdbcClass()).newInstance();
 			conn = DriverManager.getConnection(config.getJdbcURL(), config.getJdbcUser(), config.getJdbcPwd());
-			logger.info("Connected successfully");
+			log.info("Connected successfully");
 			// set the AutoCommit to false for this connection. 
 			// commit must be called explicitly! 
 			conn.setAutoCommit(false);
-			logger.info("AutoCommit is " + conn.getAutoCommit());
+			log.info("AutoCommit is " + conn.getAutoCommit());
 
 		} catch (Exception e)
         {
-			logger.severe("Failed to connect directly to '" + config.getJdbcURL() + "' / User=" +
config.getJdbcUser());
-			logger.severe(e.toString());
+			log.error("Failed to connect directly to '" + config.getJdbcURL() + "' / User=" + config.getJdbcUser());
+			log.error(e.toString());
 			throw new RuntimeException(e);
 		}
 		return conn;
 	}
 
     /**
-     * Returns the correspondig DatabaseDriver for a given database provider / vendor
+     * Returns the corresponding DatabaseDriver for a given database provider / vendor
      */
     private static DBDatabaseDriver getDatabaseDriver(String provider, Connection conn)
     {
@@ -259,7 +261,7 @@ public class SampleApp 
 	 */
 	private static boolean databaseExists(Connection conn)
     {
-		// Check wether DB exists
+		// Check whether DB exists
 		DBCommand cmd = db.createCommand();
 		cmd.select(db.DEPARTMENTS.count());
 		// Check using "select count(*) from DEPARTMENTS"
@@ -367,11 +369,11 @@ public class SampleApp 
 	 * For processing the rows there are three options available:
 	 * 
 	 *   QueryType.Reader:
-	 *     Interates through all rows and prints field values as tabbed text.
+	 *     Iterates through all rows and prints field values as tabbed text.
 	 *      
      *   QueryType.BeanList:
      *     Obtains the query result as a list of JavaBean objects of type SampleBean.
-     *     It then iterates throuh the list of beans and uses bean.toString() for printing.
+     *     It then iterates through the list of beans and uses bean.toString() for printing.
      *     
      *   QueryType.XmlDocument:
      *     Obtains the query result as an XML-Document and prints the document.

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleConfig.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleConfig.java?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleConfig.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleConfig.java
Sun Feb  6 22:22:57 2011
@@ -18,9 +18,11 @@
  */
 package org.apache.empire.samples.db;
 
-import org.apache.commons.logging.LogFactory;
+import org.apache.empire.commons.Errors;
 import org.apache.empire.xml.XMLConfiguration;
+import org.apache.empire.xml.XMLUtil;
 import org.apache.log4j.xml.DOMConfigurator;
+import org.w3c.dom.Element;
 /**
  * <PRE>
  * The SampleConfig class provides access to configuration settings.
@@ -30,6 +32,8 @@ import org.apache.log4j.xml.DOMConfigura
  */
 public class SampleConfig extends XMLConfiguration
 {
+    // the logging configuration root node name
+    private final String loggingNodeName = "log4j:configuration";
 
     private String databaseProvider = "hsqldb";
 
@@ -48,13 +52,15 @@ public class SampleConfig extends XMLCon
      * 
      * @param filename the file to read
      * 
-     * @return true on succes
+     * @return true on success
      */
     public boolean init(String filename)
     {
         // Read the properties file
-        if (super.init(filename, false, true) == false)
+        if (super.init(filename, false) == false)
             return false;
+        // Init Logging
+        initLogging();
         // Done
         if (readProperties(this, "properties")==false)
             return false;
@@ -62,6 +68,30 @@ public class SampleConfig extends XMLCon
         return readProperties(this, "properties-" + databaseProvider);
     }
 
+    /**
+     * Init logging using Log4J's DOMConfigurator 
+     * @return
+     */
+    private boolean initLogging()
+    {
+        // Get configuration root node
+        Element rootNode = getRootNode();
+        if (rootNode == null)
+            return error(Errors.ObjectNotValid, getClass().getName());
+        // Find log configuration node
+        Element loggingNode = XMLUtil.findFirstChild(rootNode, loggingNodeName);
+        if (loggingNode == null)
+        {   // log configuration node not found
+            log.error("Log configuration node {} has not been found. Logging has not been
configured.", loggingNodeName);
+            return error(Errors.ItemNotFound, loggingNodeName);
+        }
+        // Init Log4J
+        DOMConfigurator.configure(loggingNode);
+        // done
+        log.info("Logging sucessfully configured from node {}.", loggingNodeName);
+        return success();
+    }
+    
     public String getDatabaseProvider()
     {
         return databaseProvider;

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/src/main/java/org/apache/empire/samples/cxf/wssample/server/SampleConfig.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/src/main/java/org/apache/empire/samples/cxf/wssample/server/SampleConfig.java?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/src/main/java/org/apache/empire/samples/cxf/wssample/server/SampleConfig.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/src/main/java/org/apache/empire/samples/cxf/wssample/server/SampleConfig.java
Sun Feb  6 22:22:57 2011
@@ -18,9 +18,7 @@
  */
 package org.apache.empire.samples.cxf.wssample.server;
 
-import org.apache.commons.logging.LogFactory;
 import org.apache.empire.xml.XMLConfiguration;
-import org.apache.log4j.xml.DOMConfigurator;
 
 public class SampleConfig extends XMLConfiguration {
 
@@ -41,11 +39,11 @@ public class SampleConfig extends XMLCon
 	 * 
 	 * @param filename the file
 	 * 
-	 * @return true on succes
+	 * @return true on success
 	 */
 	public boolean init(String filename) {
 		// Read the properties file
-		if (super.init(filename, false, true) == false)
+		if (super.init(filename, false) == false)
 			return false;
 		// Done
 		if (readProperties(this, "properties")==false)

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/SampleConfig.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/SampleConfig.java?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/SampleConfig.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/SampleConfig.java
Sun Feb  6 22:22:57 2011
@@ -18,9 +18,7 @@
  */
 package org.apache.empire.struts2.websample.web;
 
-import org.apache.commons.logging.LogFactory;
 import org.apache.empire.xml.XMLConfiguration;
-import org.apache.log4j.xml.DOMConfigurator;
 
 public class SampleConfig extends XMLConfiguration {
 	
@@ -38,7 +36,7 @@ public class SampleConfig extends XMLCon
 	 */
 	public boolean init(String filename) {
 		// Read the properties file
-		if (super.init(filename, false, true) == false)
+		if (super.init(filename, false) == false)
 			return false;
 		// Done
 		if (readProperties(this, "properties") == false)

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/SampleConfig.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/SampleConfig.java?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/SampleConfig.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/SampleConfig.java
Sun Feb  6 22:22:57 2011
@@ -18,9 +18,7 @@
  */
 package org.apache.empire.struts2.websample.web;
 
-import org.apache.commons.logging.LogFactory;
 import org.apache.empire.xml.XMLConfiguration;
-import org.apache.log4j.xml.DOMConfigurator;
 
 public class SampleConfig extends XMLConfiguration {
 
@@ -41,11 +39,11 @@ public class SampleConfig extends XMLCon
 	 * 
 	 * @param filename the file to read 
 	 * 
-	 * @return true on succes 
+	 * @return true on success 
 	 */
 	public boolean init(String filename) {
 		// Read the properties file
-		if (super.init(filename, false, true) == false)
+		if (super.init(filename, false) == false)
 			return false;
 		// Done
 		if (readProperties(this, "properties")==false)

Modified: incubator/empire-db/trunk/empire-db/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/pom.xml?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/pom.xml (original)
+++ incubator/empire-db/trunk/empire-db/pom.xml Sun Feb  6 22:22:57 2011
@@ -31,14 +31,9 @@
 			<groupId>commons-beanutils</groupId>
 			<artifactId>commons-beanutils</artifactId>
 		</dependency>
-		<!--<dependency>
-			<groupId>commons-collections</groupId>
-			<artifactId>commons-collections</artifactId>
-		</dependency>-->
 		<dependency>
 			<groupId>org.slf4j</groupId>
 			<artifactId>slf4j-api</artifactId>
-			<version>1.6.1</version>
 		</dependency>
 		<!-- TEST -->
 		<dependency>

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java
Sun Feb  6 22:22:57 2011
@@ -55,18 +55,17 @@ public class XMLConfiguration extends Er
     // Logger (not final!)
     protected static Logger log = LoggerFactory.getLogger(XMLConfiguration.class);
 
-    private Element    configRootNode  = null;
+    private Element configRootNode = null;
 
     /**
      * Initialize the configuration.
      * 
      * @param filename the file
      * @param fromResource will read from the classpath if true
-     * @param initLogging set to true to set up logging
      * 
-     * @return true on succes
+     * @return true on success
      */
-    public boolean init(String filename, boolean fromResource, boolean initLogging)
+    public boolean init(String filename, boolean fromResource)
     {
         // Read the properties file
         if (readConfiguration(filename, fromResource) == false)
@@ -74,6 +73,15 @@ public class XMLConfiguration extends Er
         // Done
         return success();
     }
+    
+    /**
+     * returns the configuration root element or null if init() has not been called.
+     * @return the configuration root element
+     */
+    public Element getRootNode()
+    {
+        return configRootNode;
+    }
 
     /**
      * Reads the configuration file and parses the XML Configuration.
@@ -144,7 +152,7 @@ public class XMLConfiguration extends Er
             return error(Errors.InvalidArg, null, "bean");
         if (StringUtils.isValid(propertiesNodeName) == false)
             return error(Errors.InvalidArg, null, "propertiesNodeName");
-        // Get Configuraiton Node
+        // Get configuration node
         Element propertiesNode = XMLUtil.findFirstChild(configRootNode, propertiesNodeName);
         if (propertiesNode == null)
         { // Configuration

Modified: incubator/empire-db/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/pom.xml?rev=1067788&r1=1067787&r2=1067788&view=diff
==============================================================================
--- incubator/empire-db/trunk/pom.xml (original)
+++ incubator/empire-db/trunk/pom.xml Sun Feb  6 22:22:57 2011
@@ -215,16 +215,30 @@
 				<version>${project.version}</version>
 				<type>jar</type>
 			</dependency>
+			<!-- logging -->
+			<dependency>
+				<groupId>org.slf4j</groupId>
+				<artifactId>slf4j-api</artifactId>
+				<version>1.6.1</version>
+			</dependency>
+			<dependency>
+				<groupId>org.slf4j</groupId>
+				<artifactId>slf4j-log4j12</artifactId>
+				<version>1.6.1</version>
+			</dependency>
+			<!-- commons -->			
 			<dependency>
 				<groupId>commons-beanutils</groupId>
 				<artifactId>commons-beanutils</artifactId>
 				<version>1.7.0</version>
 			</dependency>
+			<!-- hsqldb -->			
 			<dependency>
 				<groupId>hsqldb</groupId>
 				<artifactId>hsqldb</artifactId>
 				<version>1.8.0.10</version>
 			</dependency>
+			<!-- struts2 -->			
 			<dependency>
 				<groupId>org.apache.struts</groupId>
 				<artifactId>struts2-core</artifactId>



Mime
View raw message