Package org.springframework.cache.interceptor

# Class AbstractCacheResolver

java.lang.Object
org.springframework.cache.interceptor.AbstractCacheResolver

All Implemented Interfaces:
  `org.springframework.beans.factory.InitializingBean`, `CacheResolver`

Direct Known Subclasses:
  `NamedCacheResolver`, `SimpleCacheResolver`

public abstract class AbstractCacheResolver extends Object implements CacheResolver, org.springframework.beans.factory.InitializingBean
A base `CacheResolver` implementation that requires the concrete implementation to provide the collection of cache name(s) based on the invocation context.

Since:
  4.1
Author:
  Stephane Nicoll, Juergen Hoeller

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`AbstractCacheResolver()`
Construct a new `AbstractCacheResolver`.
`protected`
`AbstractCacheResolver(CacheManager cacheManager)`
Construct a new `AbstractCacheResolver` for the given `CacheManager`.

## Method Summary

Modifier and Type
Method
Description
`void`
`afterPropertiesSet()`
`CacheManager`
`getCacheManager()`
Return the `CacheManager` that this instance uses.
`protected abstract Collection<String>`
`getCacheNames(CacheOperationInvocationContext<?> context)`
Provide the name of the cache(s) to resolve against the current cache manager.
`Collection<? extends Cache>`
`resolveCaches(CacheOperationInvocationContext<?> context)`
Return the cache(s) to use for the specified invocation.
`void`
`setCacheManager(CacheManager cacheManager)`
Set the `CacheManager` that this instance should use.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### AbstractCacheResolver

protected AbstractCacheResolver()
Construct a new `AbstractCacheResolver`.

See Also:
  - `setCacheManager(org.springframework.cache.CacheManager)`

### AbstractCacheResolver

protected AbstractCacheResolver(CacheManager cacheManager)
Construct a new `AbstractCacheResolver` for the given `CacheManager`.

Parameters:
  `cacheManager` - the CacheManager to use

## Method Details

### setCacheManager

public void setCacheManager(CacheManager cacheManager)
Set the `CacheManager` that this instance should use.

### getCacheManager

public CacheManager getCacheManager()
Return the `CacheManager` that this instance uses.

### afterPropertiesSet

public void afterPropertiesSet()

Specified by:
  `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`

### resolveCaches

public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context)
Description copied from interface: `CacheResolver`
Return the cache(s) to use for the specified invocation.

Specified by:
  `resolveCaches` in interface `CacheResolver`
Parameters:
  `context` - the context of the particular invocation
Returns:
  the cache(s) to use (never `null`)

### getCacheNames

@Nullable protected abstract Collection<String> getCacheNames(CacheOperationInvocationContext<?> context)
Provide the name of the cache(s) to resolve against the current cache manager.

It is acceptable to return `null` to indicate that no cache could be resolved for this invocation.

Parameters:
  `context` - the context of the particular invocation
Returns:
  the cache name(s) to resolve, or `null` if no cache should be resolved