Class ComposableCacheResolver<T extends GemFireCache>
java.lang.Object
org.springframework.data.gemfire.support.AbstractCachingCacheResolver<T>
org.springframework.data.gemfire.support.ComposableCacheResolver<T>
- All Implemented Interfaces:
Supplier<T>,CacheResolver<T>
public class ComposableCacheResolver<T extends GemFireCache>
extends AbstractCachingCacheResolver<T>
Composition of
CacheResolvers using
the Composite Software Design Pattern that acts,
and can be referred to, as a single instance of CacheResolver.
This implementation also supports caching the result of the resolution of the GemFireCache
instance reference.- Since:
- 2.3.0
- Author:
- John Blum
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedComposableCacheResolver(CacheResolver<T> cacheResolverOne, CacheResolver<T> cacheResolverTwo) Constructs a new instance ofComposableCacheResolverinitialized and composed with the givenCacheResolversforming the composition. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends GemFireCache>
CacheResolver<T>compose(Iterable<CacheResolver<T>> cacheResolvers) Factory method used to compose anIterablecollection ofCacheResolversin a composition.static <T extends GemFireCache>
CacheResolver<T>compose(CacheResolver<T>... cacheResolvers) Factory method used to compose an array ofCacheResolversin a composition.static <T extends GemFireCache>
CacheResolver<T>compose(CacheResolver<T> one, CacheResolver<T> two) Null-safe factory method used to compose twoCacheResolverobjects in a composition.Resolves the first, single reference to aGemFireCache, handling anyExceptionsthrowing by the composedCacheResolvers, such as aCacheClosedException.protected CacheResolver<T>Returns a reference to the first, non-null, configuredCacheResolverin the composition.protected CacheResolver<T>Returns a reference to the second, non-null, configuredCacheResolverin the composition.Methods inherited from class org.springframework.data.gemfire.support.AbstractCachingCacheResolver
resolveMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.gemfire.CacheResolver
get
-
Constructor Details
-
ComposableCacheResolver
protected ComposableCacheResolver(@NonNull CacheResolver<T> cacheResolverOne, @NonNull CacheResolver<T> cacheResolverTwo) Constructs a new instance ofComposableCacheResolverinitialized and composed with the givenCacheResolversforming the composition.- Parameters:
cacheResolverOne- firstCacheResolverin the composition.cacheResolverTwo- secondCacheResolverin the composition.- Throws:
IllegalArgumentException- if eitherCacheResolverargument is null.- See Also:
-
-
Method Details
-
compose
@Nullable public static <T extends GemFireCache> CacheResolver<T> compose(@Nullable CacheResolver<T>... cacheResolvers) Factory method used to compose an array ofCacheResolversin a composition.- Type Parameters:
T-subclassofGemFireCache.- Parameters:
cacheResolvers- array ofCacheResolversto compose; may be null.- Returns:
- a composition from the array of
CacheResolvers; may be null. - See Also:
-
compose
@Nullable public static <T extends GemFireCache> CacheResolver<T> compose(@Nullable Iterable<CacheResolver<T>> cacheResolvers) Factory method used to compose anIterablecollection ofCacheResolversin a composition.- Type Parameters:
T-subclassofGemFireCache.- Parameters:
cacheResolvers-Iterablecollection ofCacheResolversto compose; may be null.- Returns:
- a composition from the
Iterablecollection ofCacheResolvers; may be null. - See Also:
-
compose
@Nullable public static <T extends GemFireCache> CacheResolver<T> compose(@Nullable CacheResolver<T> one, @Nullable CacheResolver<T> two) Null-safe factory method used to compose twoCacheResolverobjects in a composition.- Type Parameters:
T-subclassofGemFireCache.- Parameters:
one- firstCacheResolverin the composition.two- secondCacheResolverin the composition.- Returns:
- the first
CacheResolverif the secondCacheResolveris null. Return the secondCacheResolverif the firstCacheResolveris null. Otherwise, return a composition of bothCacheResolverone and two as aComposableCacheResolver. - See Also:
-
getCacheResolverOne
Returns a reference to the first, non-null, configuredCacheResolverin the composition.- Returns:
- a reference to the first
CacheResolverin the composition. - See Also:
-
getCacheResolverTwo
Returns a reference to the second, non-null, configuredCacheResolverin the composition.- Returns:
- a reference to the second
CacheResolverin the composition. - See Also:
-
doResolve
Resolves the first, single reference to aGemFireCache, handling anyExceptionsthrowing by the composedCacheResolvers, such as aCacheClosedException. This method may ultimately still result in a thrownException, but it will make a best effort to exhaustively consult all composedCacheResolvers.- Specified by:
doResolvein classAbstractCachingCacheResolver<T extends GemFireCache>- Returns:
- the first, single resolved reference to a
GemFireCache. - See Also:
-