[infinispan-commits] Infinispan SVN: r1308 - trunk/query/src/main/java/org/infinispan/query/backend.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Thu Dec 17 17:59:48 EST 2009


Author: manik.surtani at jboss.com
Date: 2009-12-17 17:59:47 -0500 (Thu, 17 Dec 2009)
New Revision: 1308

Modified:
   trunk/query/src/main/java/org/infinispan/query/backend/QueryInterceptor.java
Log:
Better logging

Modified: trunk/query/src/main/java/org/infinispan/query/backend/QueryInterceptor.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/backend/QueryInterceptor.java	2009-12-17 22:31:10 UTC (rev 1307)
+++ trunk/query/src/main/java/org/infinispan/query/backend/QueryInterceptor.java	2009-12-17 22:59:47 UTC (rev 1308)
@@ -13,13 +13,14 @@
 import org.infinispan.factories.annotations.Inject;
 import org.infinispan.interceptors.base.CommandInterceptor;
 import org.infinispan.marshall.MarshalledValue;
-import static org.infinispan.query.backend.KeyTransformationHandler.keyToString;
 
 import javax.transaction.TransactionManager;
 import java.io.Serializable;
 import java.util.Map;
 import java.util.Set;
 
+import static org.infinispan.query.backend.KeyTransformationHandler.keyToString;
+
 /**
  * This interceptor will be created when the System Property "infinispan.query.indexLocalOnly" is "false"
  * <p/>
@@ -38,9 +39,6 @@
 
    @Inject
    public void init(SearchFactoryImplementor searchFactory, TransactionManager transactionManager) {
-
-      if (log.isDebugEnabled()) log.debug("Entered QueryInterceptor.init()");
-
       this.searchFactory = searchFactory;
       this.transactionManager = transactionManager;
    }
@@ -56,38 +54,26 @@
       // do the actual put first.
       Object toReturn = invokeNextInterceptor(ctx, command);
 
-      if (shouldModifyIndexes(ctx)) {
+      if (shouldModifyIndexes(ctx))
          addToIndexes(extractValue(command.getValue()), extractValue(command.getKey()));
-      }
 
-
       return toReturn;
    }
 
    @Override
    public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command) throws Throwable {
-
-      if (log.isDebugEnabled()) log.debug("Entered QueryInterceptor.visitRemoveCommand()");
-
       // remove the object out of the cache first.
       Object valueRemoved = invokeNextInterceptor(ctx, command);
 
-      if (log.isDebugEnabled()) log.debug("Transaction Manager is " + transactionManager);
-
-      if (command.isSuccessful() && shouldModifyIndexes(ctx)) {
+      if (command.isSuccessful() && shouldModifyIndexes(ctx))
          removeFromIndexes(extractValue(valueRemoved), extractValue(command.getKey()));
-      }
 
       return valueRemoved;
-
    }
 
 
    @Override
    public Object visitReplaceCommand(InvocationContext ctx, ReplaceCommand command) throws Throwable {
-
-      if (log.isDebugEnabled()) log.debug("Entered the QueryInterceptor.visitReplaceCommand()");
-
       Object valueReplaced = invokeNextInterceptor(ctx, command);
       if (valueReplaced != null && shouldModifyIndexes(ctx)) {
 
@@ -103,9 +89,6 @@
 
    @Override
    public Object visitPutMapCommand(InvocationContext ctx, PutMapCommand command) throws Throwable {
-
-      if (log.isDebugEnabled()) log.debug("Entered the QueryInterceptor.visitPutMapCommand()");
-
       Object mapPut = invokeNextInterceptor(ctx, command);
 
       if (shouldModifyIndexes(ctx)) {
@@ -122,13 +105,10 @@
 
    @Override
    public Object visitClearCommand(InvocationContext ctx, ClearCommand command) throws Throwable {
-
-      if (log.isDebugEnabled()) log.debug("Entered the QueryInterceptor.visitClearCommand()");
-
       Object returnValue = invokeNextInterceptor(ctx, command);
 
       if (shouldModifyIndexes(ctx)) {
-         if (log.isDebugEnabled()) log.debug("shouldModifyIndexes() is true and we can clear the indexes");
+         if (trace) log.trace("shouldModifyIndexes() is true and we can clear the indexes");
 
          Set<Class<?>> classes = searchFactory.getDocumentBuildersIndexedEntities().keySet();
          for (Class c : classes) {
@@ -144,12 +124,12 @@
 
    // Method that will be called when data needs to be added into Lucene.
    protected void addToIndexes(Object value, Object key) {
-      if (log.isDebugEnabled()) log.debug("Adding to indexes for key [{0}] and value [{0}]", key, value);
+      if (trace) log.trace("Adding to indexes for key [{0}] and value [{0}]", key, value);
 
       // The key here is the String representation of the key that is stored in the cache.
       // The key is going to be the documentID for Lucene.
       // The object parameter is the actual value that needs to be put into lucene.
-
+      if (value == null) throw new NullPointerException("Cannot handle a null value!");
       TransactionContext transactionContext = new TransactionalEventTransactionContext(transactionManager);
       searchFactory.getWorker().performWork(new Work<Object>(value, keyToString(key), WorkType.ADD), transactionContext);
    }
@@ -161,7 +141,7 @@
       // The key here is the String representation of the key that is stored in the cache.
       // The key is going to be the documentID for Lucene.
       // The object parameter is the actual value that needs to be removed from lucene.
-
+      if (value == null) throw new NullPointerException("Cannot handle a null value!");
       TransactionContext transactionContext = new TransactionalEventTransactionContext(transactionManager);
       searchFactory.getWorker().performWork(new Work<Object>(value, keyToString(key), WorkType.DELETE), transactionContext);
    }



More information about the infinispan-commits mailing list