Author: mriou
Date: Tue Feb  6 14:04:22 2007
New Revision: 504320

URL: http://svn.apache.org/viewvc?view=rev&rev=504320
Log:
Added LoggingDataSourceWrapper to log datasource and connections usages.

Modified:
    incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java

Modified: 
incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java?view=diff&rev=504320&r1=504319&r2=504320
==============================================================================
--- incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java 
(original)
+++ incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java 
Tue Feb  6 14:04:22 2007
@@ -19,22 +19,6 @@
 
 package org.apache.ode.jbi;
 
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.Properties;
-import java.util.concurrent.Executors;
-
-import javax.jbi.JBIException;
-import javax.jbi.component.ComponentContext;
-import javax.jbi.component.ComponentLifeCycle;
-import javax.jbi.component.ServiceUnitManager;
-import javax.management.ObjectName;
-import javax.naming.InitialContext;
-import javax.transaction.TransactionManager;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.derby.jdbc.EmbeddedDriver;
@@ -44,10 +28,27 @@
 import org.apache.ode.bpel.scheduler.quartz.QuartzSchedulerImpl;
 import org.apache.ode.jbi.msgmap.Mapper;
 import org.apache.ode.store.ProcessStoreImpl;
+import org.apache.ode.utils.LoggingDataSourceWrapper;
 import org.apache.ode.utils.fs.TempFileManager;
 import org.opentools.minerva.MinervaPool;
 import org.opentools.minerva.MinervaPool.PoolType;
 
+import javax.jbi.JBIException;
+import javax.jbi.component.ComponentContext;
+import javax.jbi.component.ComponentLifeCycle;
+import javax.jbi.component.ServiceUnitManager;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.Properties;
+import java.util.concurrent.Executors;
+
 /**
  * This class implements ComponentLifeCycle. The JBI framework will start this
  * engine class automatically when JBI framework starts up.
@@ -55,6 +56,7 @@
 public class OdeLifeCycle implements ComponentLifeCycle {
     private static final Messages __msgs = 
Messages.getMessages(Messages.class);
     private static final Log __log = LogFactory.getLog(OdeLifeCycle.class);
+    private static final Log __logSql = 
LogFactory.getLog("org.apache.ode.sql");
 
     private OdeSUManager _suManager = null;
     private boolean _initSuccess = false;
@@ -158,7 +160,11 @@
 
     private void initExternalDb() throws JBIException {
         try {
-            _ode._dataSource = lookupInJndi(_ode._config.getDbDataSource());
+            if (__logSql.isDebugEnabled())
+                _ode._dataSource = new LoggingDataSourceWrapper((DataSource)
+                        lookupInJndi(_ode._config.getDbDataSource()), 
__logSql);
+            else
+                _ode._dataSource = (DataSource) 
lookupInJndi(_ode._config.getDbDataSource());
             
__log.info(__msgs.msgOdeUsingExternalDb(_ode._config.getDbDataSource()));
         } catch (Exception ex) {
             String msg = 
__msgs.msgOdeInitExternalDbFailed(_ode._config.getDbDataSource());
@@ -203,7 +209,10 @@
             throw new JBIException(errmsg,ex);
         }
 
-        _ode._dataSource = minervaPool.createDataSource();
+        if (__logSql.isDebugEnabled())
+            _ode._dataSource = new 
LoggingDataSourceWrapper(minervaPool.createDataSource(), __logSql);
+        else _ode._dataSource = minervaPool.createDataSource();
+
         _needDerbyShutdown = true;
         _derbyUrl = url;
     }
@@ -302,10 +311,10 @@
             try {
                 _connector.start();
             } catch (Exception e) {
-
+
                 __log.error("Failed to initialize JCA connector (check 
security manager configuration)");
                 __log.debug("Failed to initialize JCA connector (check 
security manager configuration)",e);
-
+
             }
         }
     }


Reply via email to