jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1088987 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryObjectModelImpl.java
Date Tue, 05 Apr 2011 11:38:44 GMT
Author: jukka
Date: Tue Apr  5 11:38:44 2011
New Revision: 1088987

URL: http://svn.apache.org/viewvc?rev=1088987&view=rev
Log:
JCR-2934: SQL2 queries are not logged

Patch by Alex Parvulescu

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryObjectModelImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryObjectModelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryObjectModelImpl.java?rev=1088987&r1=1088986&r2=1088987&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryObjectModelImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryObjectModelImpl.java
Tue Apr  5 11:38:44 2011
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.query;
 
+import java.text.NumberFormat;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -38,6 +39,8 @@ import org.apache.jackrabbit.core.sessio
 import org.apache.jackrabbit.spi.commons.query.qom.BindVariableValueImpl;
 import org.apache.jackrabbit.spi.commons.query.qom.DefaultTraversingQOMTreeVisitor;
 import org.apache.jackrabbit.spi.commons.query.qom.QueryObjectModelTree;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * <code>QueryObjectModelImpl</code> implements the query object model.
@@ -45,6 +48,11 @@ import org.apache.jackrabbit.spi.commons
 public class QueryObjectModelImpl extends QueryImpl implements QueryObjectModel {
 
     /**
+     * The logger instance for this class
+     */
+    private static final Logger log = LoggerFactory.getLogger(QueryObjectModelImpl.class);
+
+    /**
      * The query object model tree.
      */
     protected QueryObjectModelTree qomTree;
@@ -109,14 +117,22 @@ public class QueryObjectModelImpl extend
     }
 
     public QueryResult execute() throws RepositoryException {
-        QueryEngine engine = new QueryEngine(
-                sessionContext.getSessionImpl(), lqf, variables);
-        return engine.execute(
-                getColumns(), getSource(), getConstraint(),
-                getOrderings(), offset, limit);
+        QueryEngine engine = new QueryEngine(sessionContext.getSessionImpl(),
+                lqf, variables);
+        long time = System.currentTimeMillis();
+        QueryResult qr = engine.execute(getColumns(), getSource(),
+                getConstraint(), getOrderings(), offset, limit);
+        time = System.currentTimeMillis() - time;
+        if (log.isDebugEnabled()) {
+            NumberFormat format = NumberFormat.getNumberInstance();
+            format.setMinimumFractionDigits(2);
+            format.setMaximumFractionDigits(2);
+            String seconds = format.format((double) time / 1000);
+            log.debug("executed in " + seconds + " s. (" + statement + ")");
+        }
+        return qr;
     }
 
-
     @Override
     public String[] getBindVariableNames() {
         return variables.keySet().toArray(new String[variables.size()]);



Mime
View raw message