[infinispan-commits] Infinispan SVN: r1270 - trunk/core/src/main/java/org/infinispan/config.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Thu Dec 10 06:14:08 EST 2009


Author: manik.surtani at jboss.com
Date: 2009-12-10 06:14:08 -0500 (Thu, 10 Dec 2009)
New Revision: 1270

Modified:
   trunk/core/src/main/java/org/infinispan/config/Configuration.java
   trunk/core/src/main/java/org/infinispan/config/OverrideConfigurationVisitor.java
Log:
Improvements in configuration merging

Modified: trunk/core/src/main/java/org/infinispan/config/Configuration.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/Configuration.java	2009-12-10 06:35:10 UTC (rev 1269)
+++ trunk/core/src/main/java/org/infinispan/config/Configuration.java	2009-12-10 11:14:08 UTC (rev 1270)
@@ -452,10 +452,14 @@
       this.clustering.async.setAsyncMarshalling(useAsyncMarshalling);
    }
 
-   public void setQueryConfigurationBean(QueryConfigurationBean indexing) {
-      this.indexing = indexing;
+   public void setIndexingEnabled(boolean enabled) {
+      this.indexing.setEnabled(enabled);
    }
 
+   public void setIndexLocalOnly(boolean indexLocalOnly) {
+      this.indexing.setIndexLocalOnly(indexLocalOnly);
+   }
+
    // ------------------------------------------------------------------------------------------------------------
    //   GETTERS
    // ------------------------------------------------------------------------------------------------------------
@@ -488,10 +492,14 @@
       return invocationBatching.enabled ;
    }
    
-   public QueryConfigurationBean getQueryConfigurationBean() {
-      return indexing;
+   public boolean isIndexingEnabled() {
+      return indexing.isEnabled();
    }
 
+   public boolean isIndexLocalOnly() {
+      return indexing.isIndexLocalOnly();
+   }
+
    public boolean isFetchInMemoryState() {
       return clustering.stateRetrieval.fetchInMemoryState;
    }
@@ -676,6 +684,7 @@
          if (lazyDeserialization != null) dolly.lazyDeserialization = (LazyDeserialization) lazyDeserialization.clone();
          if (invocationBatching != null) dolly.invocationBatching = (InvocationBatching) invocationBatching.clone();
          if (deadlockDetection != null) dolly.deadlockDetection = (DeadlockDetectionType) deadlockDetection.clone();
+         if (indexing != null) dolly.indexing = (QueryConfigurationBean) indexing.clone();
          return dolly;
       } catch (CloneNotSupportedException e) {
          throw new CacheException("Unexpected!",e);
@@ -1820,7 +1829,7 @@
    }
    
    /**
-    * @configRef name="indexing",desc="Configures indexing of entries in the cache for searching."
+    * @configRef name="indexing",desc="Configures indexing of entries in the cache for searching.  Note that infinispan-query.jar and its dependencies needs to be available if this option is to be used."
     */
    @XmlAccessorType(XmlAccessType.PROPERTY)
    public static class QueryConfigurationBean extends AbstractConfigurationBean {
@@ -1828,10 +1837,10 @@
        /** The serialVersionUID */
        private static final long serialVersionUID = 2891683014353342549L;
 
-       /** @configRef desc="If enabled, entries will be indexed when they are added to the cache.  INdexes will be updated as entries change or are removed." */
+       /** @configRef desc="If enabled, entries will be indexed when they are added to the cache.  Indexes will be updated as entries change or are removed." */
        protected Boolean enabled = false;
 
-       /** @configRef desc="If true, only index changes made locally, ignoring remote changes.  This is useful if indexes are shared across a cluster." */
+       /** @configRef desc="If true, only index changes made locally, ignoring remote changes.  This is useful if indexes are shared across a cluster to prevent redundant indexing of updates." */
        protected Boolean indexLocalOnly = false;
 
        public Boolean isEnabled() {
@@ -1887,6 +1896,18 @@
        protected boolean hasComponentStarted() {
            return false;
        }
+
+      @Override
+      public QueryConfigurationBean clone() {
+         try {
+            QueryConfigurationBean dolly = (QueryConfigurationBean) super.clone();
+            dolly.enabled = enabled;
+            dolly.indexLocalOnly = indexLocalOnly;
+            return dolly;
+         } catch (CloneNotSupportedException shouldNotHappen) {
+            throw new RuntimeException("Should not happen!", shouldNotHappen);
+         }
+      }
    }
 
 

Modified: trunk/core/src/main/java/org/infinispan/config/OverrideConfigurationVisitor.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/OverrideConfigurationVisitor.java	2009-12-10 06:35:10 UTC (rev 1269)
+++ trunk/core/src/main/java/org/infinispan/config/OverrideConfigurationVisitor.java	2009-12-10 11:14:08 UTC (rev 1270)
@@ -21,28 +21,15 @@
  */
 package org.infinispan.config;
 
+import org.infinispan.CacheException;
+import org.infinispan.config.Configuration.*;
+import org.infinispan.util.ReflectionUtil;
+
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
-import java.util.Map.Entry;
 
-import org.infinispan.CacheException;
-import org.infinispan.config.Configuration.AsyncType;
-import org.infinispan.config.Configuration.BooleanAttributeType;
-import org.infinispan.config.Configuration.ClusteringType;
-import org.infinispan.config.Configuration.CustomInterceptorsType;
-import org.infinispan.config.Configuration.DeadlockDetectionType;
-import org.infinispan.config.Configuration.EvictionType;
-import org.infinispan.config.Configuration.ExpirationType;
-import org.infinispan.config.Configuration.HashType;
-import org.infinispan.config.Configuration.L1Type;
-import org.infinispan.config.Configuration.LockingType;
-import org.infinispan.config.Configuration.StateRetrievalType;
-import org.infinispan.config.Configuration.SyncType;
-import org.infinispan.config.Configuration.TransactionType;
-import org.infinispan.config.Configuration.UnsafeType;
-import org.infinispan.util.ReflectionUtil;
-
 /**
  * OverrideConfigurationVisitor breaks down fields of Configuration object to individual components
  * and then compares them for field updates.
@@ -52,22 +39,23 @@
  */
 public class OverrideConfigurationVisitor extends AbstractConfigurationBeanVisitor {
 
-   AsyncType asyncType = null;
-   CacheLoaderManagerConfig cacheLoaderManagerConfig = null;
-   ClusteringType clusteringType = null;
-   Map <String,BooleanAttributeType> bats = new HashMap<String,BooleanAttributeType>();
+   private AsyncType asyncType = null;
+   private CacheLoaderManagerConfig cacheLoaderManagerConfig = null;
+   private ClusteringType clusteringType = null;
+   private final Map <String,BooleanAttributeType> bats = new HashMap<String,BooleanAttributeType>();
 
-   CustomInterceptorsType customInterceptorsType = null;
-   DeadlockDetectionType deadlockDetectionType = null;
-   EvictionType evictionType = null;
-   ExpirationType expirationType = null;
-   HashType hashType = null;
-   L1Type l1Type = null;
-   LockingType lockingType = null;
-   StateRetrievalType stateRetrievalType = null;
-   SyncType syncType = null;
-   TransactionType transactionType = null;
-   UnsafeType unsafeType = null;
+   private CustomInterceptorsType customInterceptorsType = null;
+   private DeadlockDetectionType deadlockDetectionType = null;
+   private EvictionType evictionType = null;
+   private ExpirationType expirationType = null;
+   private HashType hashType = null;
+   private L1Type l1Type = null;
+   private LockingType lockingType = null;
+   private StateRetrievalType stateRetrievalType = null;
+   private SyncType syncType = null;
+   private TransactionType transactionType = null;
+   private UnsafeType unsafeType = null;
+   private QueryConfigurationBean indexingType = null;
 
    public void override(OverrideConfigurationVisitor override) {
       
@@ -96,6 +84,7 @@
       overrideFields(syncType, override.syncType);
       overrideFields(transactionType, override.transactionType);
       overrideFields(unsafeType, override.unsafeType);
+      overrideFields(indexingType, override.indexingType);
    }
 
    private void overrideFields(AbstractConfigurationBean bean, AbstractConfigurationBean overrides) {
@@ -112,63 +101,83 @@
       } 
    }
 
+   @Override
    public void visitAsyncType(AsyncType bean) {
       asyncType = bean;
    }
-   
+
+   @Override
    public void visitBooleanAttributeType(BooleanAttributeType bat) {
       bats.put(bat.getFieldName(), bat);
    }
 
+   @Override
    public void visitCacheLoaderManagerConfig(CacheLoaderManagerConfig bean) {
       cacheLoaderManagerConfig = bean;
    }
 
+   @Override
    public void visitClusteringType(ClusteringType bean) {
       clusteringType = bean;
    }
 
+   @Override
    public void visitCustomInterceptorsType(CustomInterceptorsType bean) {
       customInterceptorsType = bean;
    }
 
+   @Override
    public void visitDeadlockDetectionType(DeadlockDetectionType bean) {
       deadlockDetectionType = bean;
    }
 
+   @Override
    public void visitEvictionType(EvictionType bean) {
       evictionType = bean;
    }
 
+   @Override
    public void visitExpirationType(ExpirationType bean) {
       expirationType = bean;
    }
 
+   @Override
    public void visitHashType(HashType bean) {
       hashType = bean;
    }
 
+   @Override
    public void visitL1Type(L1Type bean) {
       l1Type = bean;
    }
 
+   @Override
    public void visitLockingType(LockingType bean) {
       lockingType = bean;
    }
 
+   @Override
    public void visitStateRetrievalType(StateRetrievalType bean) {
       stateRetrievalType = bean;
    }
 
+   @Override
    public void visitSyncType(SyncType bean) {
       syncType = bean;
    }
 
+   @Override
    public void visitTransactionType(TransactionType bean) {
       transactionType = bean;
    }
 
+   @Override
    public void visitUnsafeType(UnsafeType bean) {
       unsafeType = bean;
    }
+
+   @Override
+   public void visitQueryConfigurationBean(QueryConfigurationBean bean) {
+      indexingType = bean;
+   }
 }



More information about the infinispan-commits mailing list