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
ModifierConstructorDescriptionprotected
ComposableCacheResolver
(CacheResolver<T> cacheResolverOne, CacheResolver<T> cacheResolverTwo) Constructs a new instance ofComposableCacheResolver
initialized and composed with the givenCacheResolvers
forming the composition. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends GemFireCache>
CacheResolver<T>compose
(Iterable<CacheResolver<T>> cacheResolvers) Factory method used to compose anIterable
collection ofCacheResolvers
in a composition.static <T extends GemFireCache>
CacheResolver<T>compose
(CacheResolver<T>... cacheResolvers) Factory method used to compose an array ofCacheResolvers
in a composition.static <T extends GemFireCache>
CacheResolver<T>compose
(CacheResolver<T> one, CacheResolver<T> two) Null-safe factory method used to compose twoCacheResolver
objects in a composition.Resolves the first, single reference to aGemFireCache
, handling anyExceptions
throwing by the composedCacheResolvers
, such as aCacheClosedException
.protected CacheResolver<T>
Returns a reference to the first, non-null, configuredCacheResolver
in the composition.protected CacheResolver<T>
Returns a reference to the second, non-null, configuredCacheResolver
in the composition.Methods inherited from class org.springframework.data.gemfire.support.AbstractCachingCacheResolver
resolve
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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 ofComposableCacheResolver
initialized and composed with the givenCacheResolvers
forming the composition.- Parameters:
cacheResolverOne
- firstCacheResolver
in the composition.cacheResolverTwo
- secondCacheResolver
in the composition.- Throws:
IllegalArgumentException
- if eitherCacheResolver
argument 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 ofCacheResolvers
in a composition.- Type Parameters:
T
-subclass
ofGemFireCache
.- Parameters:
cacheResolvers
- array ofCacheResolvers
to 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 anIterable
collection ofCacheResolvers
in a composition.- Type Parameters:
T
-subclass
ofGemFireCache
.- Parameters:
cacheResolvers
-Iterable
collection ofCacheResolvers
to compose; may be null.- Returns:
- a composition from the
Iterable
collection 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 twoCacheResolver
objects in a composition.- Type Parameters:
T
-subclass
ofGemFireCache
.- Parameters:
one
- firstCacheResolver
in the composition.two
- secondCacheResolver
in the composition.- Returns:
- the first
CacheResolver
if the secondCacheResolver
is null. Return the secondCacheResolver
if the firstCacheResolver
is null. Otherwise, return a composition of bothCacheResolver
one and two as aComposableCacheResolver
. - See Also:
-
getCacheResolverOne
Returns a reference to the first, non-null, configuredCacheResolver
in the composition.- Returns:
- a reference to the first
CacheResolver
in the composition. - See Also:
-
getCacheResolverTwo
Returns a reference to the second, non-null, configuredCacheResolver
in the composition.- Returns:
- a reference to the second
CacheResolver
in the composition. - See Also:
-
doResolve
Resolves the first, single reference to aGemFireCache
, handling anyExceptions
throwing 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:
doResolve
in classAbstractCachingCacheResolver<T extends GemFireCache>
- Returns:
- the first, single resolved reference to a
GemFireCache
. - See Also:
-