[infinispan-commits] Infinispan SVN: r2231 - in branches/4.1.x/core/src: test/java/org/infinispan/config and 1 other directory.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Mon Aug 16 11:50:00 EDT 2010
Author: manik.surtani at jboss.com
Date: 2010-08-16 11:50:00 -0400 (Mon, 16 Aug 2010)
New Revision: 2231
Modified:
branches/4.1.x/core/src/main/java/org/infinispan/config/Configuration.java
branches/4.1.x/core/src/main/java/org/infinispan/config/CustomInterceptorConfig.java
branches/4.1.x/core/src/main/java/org/infinispan/config/OverrideConfigurationVisitor.java
branches/4.1.x/core/src/test/java/org/infinispan/config/CustomInterceptorConfigTest.java
Log:
[ISPN-605] (Cannot add custom interceptor to the Cache programmatically)
Modified: branches/4.1.x/core/src/main/java/org/infinispan/config/Configuration.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/config/Configuration.java 2010-08-16 15:19:08 UTC (rev 2230)
+++ branches/4.1.x/core/src/main/java/org/infinispan/config/Configuration.java 2010-08-16 15:50:00 UTC (rev 2231)
@@ -758,8 +758,7 @@
* @see #getCustomInterceptors()
*/
public void setCustomInterceptors(List<CustomInterceptorConfig> customInterceptors) {
- testImmutability("customInterceptors");
- this.customInterceptors.customInterceptors = customInterceptors;
+ this.customInterceptors.setCustomInterceptors(customInterceptors);
}
public void assertValid() throws ConfigurationException {
@@ -1924,6 +1923,11 @@
public int hashCode() {
return customInterceptors != null ? customInterceptors.hashCode() : 0;
}
+
+ public void setCustomInterceptors(List<CustomInterceptorConfig> customInterceptors) {
+ testImmutability("customInterceptors");
+ this.customInterceptors = customInterceptors;
+ }
}
/**
Modified: branches/4.1.x/core/src/main/java/org/infinispan/config/CustomInterceptorConfig.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/config/CustomInterceptorConfig.java 2010-08-16 15:19:08 UTC (rev 2230)
+++ branches/4.1.x/core/src/main/java/org/infinispan/config/CustomInterceptorConfig.java 2010-08-16 15:50:00 UTC (rev 2231)
@@ -118,6 +118,12 @@
this.index = index;
this.after = after;
this.before = before;
+ overriddenConfigurationElements.add("interceptor");
+ overriddenConfigurationElements.add("isFirst");
+ overriddenConfigurationElements.add("isLast");
+ overriddenConfigurationElements.add("index");
+ overriddenConfigurationElements.add("after");
+ overriddenConfigurationElements.add("before");
}
/**
@@ -136,8 +142,20 @@
isFirst = first;
isLast = last;
this.index = index;
- this.after = after == null ? null : after.getName();
- this.before = before == null ? null : before.getName();
+ overriddenConfigurationElements.add("interceptor");
+ overriddenConfigurationElements.add("isFirst");
+ overriddenConfigurationElements.add("isLast");
+ overriddenConfigurationElements.add("index");
+
+ if (after != null) {
+ this.after = after.getName();
+ overriddenConfigurationElements.add("after");
+ }
+
+ if (before != null) {
+ this.before = before.getName();
+ overriddenConfigurationElements.add("before");
+ }
}
/**
@@ -147,6 +165,7 @@
*/
public CustomInterceptorConfig(CommandInterceptor interceptor) {
this.interceptor = interceptor;
+ overriddenConfigurationElements.add("interceptor");
}
public Properties getProperties() {
@@ -155,6 +174,7 @@
public void setProperties(Properties properties) {
this.properties = toTypedProperties(properties);
+ testImmutability("properties");
}
public Position getPosition() {
@@ -163,6 +183,7 @@
public void setPosition(Position position) {
this.position = position;
+ testImmutability("position");
}
public String getClassName() {
@@ -171,6 +192,7 @@
public void setClassName(String className) {
this.className = className;
+ testImmutability("className");
}
/**
@@ -248,6 +270,7 @@
* Returns a the interceptor that we want to add to the chain.
*/
public void setInterceptor(CommandInterceptor interceptor) {
+ testImmutability("interceptor");
this.interceptor = interceptor;
}
Modified: branches/4.1.x/core/src/main/java/org/infinispan/config/OverrideConfigurationVisitor.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/config/OverrideConfigurationVisitor.java 2010-08-16 15:19:08 UTC (rev 2230)
+++ branches/4.1.x/core/src/main/java/org/infinispan/config/OverrideConfigurationVisitor.java 2010-08-16 15:50:00 UTC (rev 2231)
@@ -85,6 +85,7 @@
overrideFields(transactionType, override.transactionType);
overrideFields(unsafeType, override.unsafeType);
overrideFields(indexingType, override.indexingType);
+ overrideFields(customInterceptorsType, override.customInterceptorsType);
}
private void overrideFields(AbstractConfigurationBean bean, AbstractConfigurationBean overrides) {
Modified: branches/4.1.x/core/src/test/java/org/infinispan/config/CustomInterceptorConfigTest.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/config/CustomInterceptorConfigTest.java 2010-08-16 15:19:08 UTC (rev 2230)
+++ branches/4.1.x/core/src/test/java/org/infinispan/config/CustomInterceptorConfigTest.java 2010-08-16 15:50:00 UTC (rev 2231)
@@ -4,6 +4,9 @@
import org.infinispan.interceptors.InvocationContextInterceptor;
import org.infinispan.interceptors.base.CommandInterceptor;
import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.test.AbstractInfinispanTest;
import org.infinispan.test.TestingUtil;
import org.infinispan.test.fwk.TestCacheManagerFactory;
import org.testng.annotations.AfterMethod;
@@ -12,9 +15,10 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Collections;
@Test(testName = "config.CustomInterceptorConfigTest", groups = "functional")
-public class CustomInterceptorConfigTest {
+public class CustomInterceptorConfigTest extends AbstractInfinispanTest {
Cache c;
CacheContainer cm;
@@ -35,6 +39,30 @@
assert i != null;
}
+ public void testCustomInterceptorsProgramatically() {
+ Configuration cfg = new Configuration();
+ cfg.setLockAcquisitionTimeout(1010);
+ CustomInterceptorConfig cic = new CustomInterceptorConfig(new DummyInterceptor(), true, false, -1, "", "");
+ cfg.setCustomInterceptors(Collections.singletonList(cic));
+ cm = new DefaultCacheManager(cfg);
+ c = cm.getCache();
+ DummyInterceptor i = TestingUtil.findInterceptor(c, DummyInterceptor.class);
+ assert i != null;
+ }
+
+
+ public void testCustomInterceptorsProgramaticallyWithOverride() {
+ Configuration cfg = new Configuration();
+ cfg.setLockAcquisitionTimeout(1010);
+ CustomInterceptorConfig cic = new CustomInterceptorConfig(new DummyInterceptor(), true, false, -1, "", "");
+ cfg.setCustomInterceptors(Collections.singletonList(cic));
+ cm = new DefaultCacheManager(new Configuration());
+ ((EmbeddedCacheManager) cm).defineConfiguration("custom", cfg);
+ c = cm.getCache("custom");
+ DummyInterceptor i = TestingUtil.findInterceptor(c, DummyInterceptor.class);
+ assert i != null;
+ }
+
@AfterMethod
public void tearDown() {
if (cm != null) cm.stop();
More information about the infinispan-commits
mailing list