You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2017/03/16 11:45:47 UTC
[2/2] cayenne git commit: Make CacheGroupHandler optional in
CacheInvalidationModuleBuilder
Make CacheGroupHandler optional in CacheInvalidationModuleBuilder
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/8ef8f122
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/8ef8f122
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/8ef8f122
Branch: refs/heads/master
Commit: 8ef8f12218c48487dbe711a8e5cfe831b1c96a9e
Parents: 17db3b1
Author: Nikita Timofeev <st...@gmail.com>
Authored: Thu Mar 16 14:44:12 2017 +0300
Committer: Nikita Timofeev <st...@gmail.com>
Committed: Thu Mar 16 14:44:12 2017 +0300
----------------------------------------------------------------------
.../cache/CacheInvalidationModuleBuilder.java | 15 +++++++++++++--
.../lifecycle/unit/CacheInvalidationCase.java | 2 +-
2 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cayenne/blob/8ef8f122/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/cache/CacheInvalidationModuleBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/cache/CacheInvalidationModuleBuilder.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/cache/CacheInvalidationModuleBuilder.java
index 881444d..92d7993 100644
--- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/cache/CacheInvalidationModuleBuilder.java
+++ b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/cache/CacheInvalidationModuleBuilder.java
@@ -22,7 +22,6 @@ package org.apache.cayenne.lifecycle.cache;
import java.util.Collection;
import java.util.HashSet;
-import org.apache.cayenne.configuration.Constants;
import org.apache.cayenne.configuration.server.ServerModule;
import org.apache.cayenne.di.Binder;
import org.apache.cayenne.di.ListBuilder;
@@ -40,6 +39,8 @@ public class CacheInvalidationModuleBuilder {
private Collection<InvalidationHandler> handlerInstances;
+ private boolean noCacheGroupsHandler;
+
public static CacheInvalidationModuleBuilder builder() {
return new CacheInvalidationModuleBuilder();
}
@@ -53,6 +54,14 @@ public class CacheInvalidationModuleBuilder {
this.handlerInstances = new HashSet<>();
}
+ /**
+ * Disable {@link CacheGroupsHandler} based on {@link CacheGroups} annotation.
+ */
+ public CacheInvalidationModuleBuilder noCacheGroupsHandler() {
+ noCacheGroupsHandler = true;
+ return this;
+ }
+
public CacheInvalidationModuleBuilder invalidationHandler(Class<? extends InvalidationHandler> handlerType) {
handlerTypes.add(handlerType);
return this;
@@ -69,7 +78,9 @@ public class CacheInvalidationModuleBuilder {
public void configure(Binder binder) {
ListBuilder<InvalidationHandler> handlers = contributeInvalidationHandler(binder);
- handlers.add(CacheGroupsHandler.class);
+ if(!noCacheGroupsHandler) {
+ handlers.add(CacheGroupsHandler.class);
+ }
handlers.addAll(handlerInstances);
for(Class<? extends InvalidationHandler> handlerType : handlerTypes) {
http://git-wip-us.apache.org/repos/asf/cayenne/blob/8ef8f122/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/unit/CacheInvalidationCase.java
----------------------------------------------------------------------
diff --git a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/unit/CacheInvalidationCase.java b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/unit/CacheInvalidationCase.java
index 2d17220..1350ce4 100644
--- a/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/unit/CacheInvalidationCase.java
+++ b/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/unit/CacheInvalidationCase.java
@@ -25,7 +25,6 @@ import org.apache.cayenne.Persistent;
import org.apache.cayenne.configuration.server.ServerRuntime;
import org.apache.cayenne.configuration.server.ServerRuntimeBuilder;
import org.apache.cayenne.di.Module;
-import org.apache.cayenne.lifecycle.cache.CacheGroups;
import org.apache.cayenne.lifecycle.cache.CacheInvalidationModuleBuilder;
import org.apache.cayenne.lifecycle.cache.InvalidationFunction;
import org.apache.cayenne.lifecycle.cache.InvalidationHandler;
@@ -53,6 +52,7 @@ public class CacheInvalidationCase {
protected ServerRuntimeBuilder configureCayenne() {
Module cacheInvalidationModule = CacheInvalidationModuleBuilder
.builder()
+ .noCacheGroupsHandler()
.invalidationHandler(G1InvalidationHandler.class)
.build();