Search in sources :

Example 1 with CacheEvictOperation

use of org.springframework.cache.interceptor.CacheEvictOperation in project spring-framework by spring-projects.

the class AnnotationCacheOperationSourceTests method multipleStereotypes.

@Test
public void multipleStereotypes() throws Exception {
    Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multipleStereotype", 3);
    Iterator<CacheOperation> it = ops.iterator();
    assertTrue(it.next() instanceof CacheableOperation);
    CacheOperation next = it.next();
    assertTrue(next instanceof CacheEvictOperation);
    assertTrue(next.getCacheNames().contains("foo"));
    next = it.next();
    assertTrue(next instanceof CacheEvictOperation);
    assertTrue(next.getCacheNames().contains("bar"));
}
Also used : CacheEvictOperation(org.springframework.cache.interceptor.CacheEvictOperation) CacheOperation(org.springframework.cache.interceptor.CacheOperation) CacheableOperation(org.springframework.cache.interceptor.CacheableOperation) Test(org.junit.Test)

Example 2 with CacheEvictOperation

use of org.springframework.cache.interceptor.CacheEvictOperation in project spring-framework by spring-projects.

the class SpringCacheAnnotationParser method parseEvictAnnotation.

CacheEvictOperation parseEvictAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, CacheEvict cacheEvict) {
    CacheEvictOperation.Builder builder = new CacheEvictOperation.Builder();
    builder.setName(ae.toString());
    builder.setCacheNames(cacheEvict.cacheNames());
    builder.setCondition(cacheEvict.condition());
    builder.setKey(cacheEvict.key());
    builder.setKeyGenerator(cacheEvict.keyGenerator());
    builder.setCacheManager(cacheEvict.cacheManager());
    builder.setCacheResolver(cacheEvict.cacheResolver());
    builder.setCacheWide(cacheEvict.allEntries());
    builder.setBeforeInvocation(cacheEvict.beforeInvocation());
    defaultConfig.applyDefault(builder);
    CacheEvictOperation op = builder.build();
    validateCacheOperation(ae, op);
    return op;
}
Also used : CacheEvictOperation(org.springframework.cache.interceptor.CacheEvictOperation)

Aggregations

CacheEvictOperation (org.springframework.cache.interceptor.CacheEvictOperation)2 Test (org.junit.Test)1 CacheOperation (org.springframework.cache.interceptor.CacheOperation)1 CacheableOperation (org.springframework.cache.interceptor.CacheableOperation)1