-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache Invalidation: Introduced InvalidationListener and event specifi…
…cation
- Loading branch information
1 parent
c331c65
commit 028bbf9
Showing
3 changed files
with
106 additions
and
9 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
...api/src/main/java/com/evolveum/midpoint/repo/api/CacheInvalidationEventSpecification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2022 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.repo.api; | ||
|
||
import java.util.Collections; | ||
import java.util.EnumSet; | ||
import java.util.Set; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.evolveum.midpoint.prism.delta.ChangeType; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; | ||
|
||
public class CacheInvalidationEventSpecification { | ||
|
||
public static final Set<ChangeType> ALL_CHANGES = Collections.unmodifiableSet(EnumSet.allOf(ChangeType.class)); | ||
public static final Set<ChangeType> MODIFY_DELETE = Collections.unmodifiableSet(EnumSet.of(ChangeType.MODIFY, ChangeType.DELETE)); | ||
public static final Set<ItemPath> ALL_PATHS = Collections.singleton(ItemPath.EMPTY_PATH); | ||
|
||
public static final Set<CacheInvalidationEventSpecification> ALL_AVAILABLE_EVENTS = Collections.singleton(of(ObjectType.class, ALL_CHANGES)); | ||
|
||
|
||
|
||
private final Class<? extends ObjectType> objectType; | ||
private final Set<ItemPath> paths; | ||
private final Set<ChangeType> changeTypes; | ||
|
||
|
||
protected CacheInvalidationEventSpecification(Class<? extends ObjectType> objectType, Set<ItemPath> paths, | ||
Set<ChangeType> changeTypes) { | ||
this.objectType = objectType; | ||
this.paths = paths; | ||
this.changeTypes = changeTypes; | ||
} | ||
|
||
public static CacheInvalidationEventSpecification of(Class<? extends ObjectType> type, Set<ChangeType> changes) { | ||
return of(type, null, changes); | ||
} | ||
|
||
public static CacheInvalidationEventSpecification of(Class<? extends ObjectType> type, Set<ItemPath> paths, | ||
Set<ChangeType> changes) { | ||
if (paths == null) { | ||
paths = ALL_PATHS; | ||
} | ||
return new CacheInvalidationEventSpecification(type, paths, changes); | ||
} | ||
|
||
@NotNull | ||
public Class<? extends ObjectType> getObjectType() { | ||
return objectType; | ||
} | ||
|
||
@NotNull | ||
Set<ItemPath> getPaths() { | ||
return paths; | ||
} | ||
|
||
@NotNull | ||
Set<ChangeType> getChangeTypes() { | ||
return changeTypes; | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
repo/repo-api/src/main/java/com/evolveum/midpoint/repo/api/CacheInvalidationListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2022 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.repo.api; | ||
|
||
import java.util.Collection; | ||
|
||
import com.evolveum.midpoint.CacheInvalidationContext; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; | ||
|
||
public interface CacheInvalidationListener { | ||
|
||
Collection<CacheInvalidationEventSpecification> getEventSpecifications(); | ||
|
||
/** | ||
* Invalidates given object(s) in all relevant caches. | ||
* @param type Type of object (null means all types). | ||
* @param oid OID of object (null means all object(s) of given type(s)). | ||
* @param clusterwide Whether to distribute this event clusterwide. | ||
* @param context Context of the invalidation request (optional). | ||
*/ | ||
<O extends ObjectType> void invalidate(Class<O> type, String oid, boolean clusterwide, CacheInvalidationContext context); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters