Search in sources :

Example 1 with CacheRemove

use of javax.cache.annotation.CacheRemove in project spring-framework by spring-projects.

the class AnnotationJCacheOperationSource method findCacheOperation.

@Override
protected JCacheOperation<?> findCacheOperation(Method method, Class<?> targetType) {
    CacheResult cacheResult = method.getAnnotation(CacheResult.class);
    CachePut cachePut = method.getAnnotation(CachePut.class);
    CacheRemove cacheRemove = method.getAnnotation(CacheRemove.class);
    CacheRemoveAll cacheRemoveAll = method.getAnnotation(CacheRemoveAll.class);
    int found = countNonNull(cacheResult, cachePut, cacheRemove, cacheRemoveAll);
    if (found == 0) {
        return null;
    }
    if (found > 1) {
        throw new IllegalStateException("More than one cache annotation found on '" + method + "'");
    }
    CacheDefaults defaults = getCacheDefaults(method, targetType);
    if (cacheResult != null) {
        return createCacheResultOperation(method, defaults, cacheResult);
    } else if (cachePut != null) {
        return createCachePutOperation(method, defaults, cachePut);
    } else if (cacheRemove != null) {
        return createCacheRemoveOperation(method, defaults, cacheRemove);
    } else {
        return createCacheRemoveAllOperation(method, defaults, cacheRemoveAll);
    }
}
Also used : CacheRemove(javax.cache.annotation.CacheRemove) CacheDefaults(javax.cache.annotation.CacheDefaults) CacheResult(javax.cache.annotation.CacheResult) CacheRemoveAll(javax.cache.annotation.CacheRemoveAll) CachePut(javax.cache.annotation.CachePut)

Example 2 with CacheRemove

use of javax.cache.annotation.CacheRemove in project spring-framework by spring-projects.

the class AnnotationJCacheOperationSource method createCacheRemoveOperation.

protected CacheRemoveOperation createCacheRemoveOperation(Method method, CacheDefaults defaults, CacheRemove ann) {
    String cacheName = determineCacheName(method, defaults, ann.cacheName());
    CacheResolverFactory cacheResolverFactory = determineCacheResolverFactory(defaults, ann.cacheResolverFactory());
    KeyGenerator keyGenerator = determineKeyGenerator(defaults, ann.cacheKeyGenerator());
    CacheMethodDetails<CacheRemove> methodDetails = createMethodDetails(method, ann, cacheName);
    CacheResolver cacheResolver = getCacheResolver(cacheResolverFactory, methodDetails);
    return new CacheRemoveOperation(methodDetails, cacheResolver, keyGenerator);
}
Also used : CacheRemove(javax.cache.annotation.CacheRemove) CacheResolver(org.springframework.cache.interceptor.CacheResolver) KeyGenerator(org.springframework.cache.interceptor.KeyGenerator) CacheKeyGenerator(javax.cache.annotation.CacheKeyGenerator) CacheResolverFactory(javax.cache.annotation.CacheResolverFactory)

Aggregations

CacheRemove (javax.cache.annotation.CacheRemove)2 CacheDefaults (javax.cache.annotation.CacheDefaults)1 CacheKeyGenerator (javax.cache.annotation.CacheKeyGenerator)1 CachePut (javax.cache.annotation.CachePut)1 CacheRemoveAll (javax.cache.annotation.CacheRemoveAll)1 CacheResolverFactory (javax.cache.annotation.CacheResolverFactory)1 CacheResult (javax.cache.annotation.CacheResult)1 CacheResolver (org.springframework.cache.interceptor.CacheResolver)1 KeyGenerator (org.springframework.cache.interceptor.KeyGenerator)1