Search in sources :

Example 1 with CacheableOperation

use of org.springframework.cache.interceptor.CacheableOperation 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 CacheableOperation

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

the class AnnotationCacheOperationSourceTests method cacheAnnotationOverride.

@Test
public void cacheAnnotationOverride() {
    Collection<CacheOperation> ops = getOps(InterfaceCacheConfig.class, "interfaceCacheableOverride");
    assertSame(1, ops.size());
    CacheOperation cacheOperation = ops.iterator().next();
    assertTrue(cacheOperation instanceof CacheableOperation);
}
Also used : CacheOperation(org.springframework.cache.interceptor.CacheOperation) CacheableOperation(org.springframework.cache.interceptor.CacheableOperation) Test(org.junit.Test)

Example 3 with CacheableOperation

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

the class SpringCacheAnnotationParser method parseCacheableAnnotation.

CacheableOperation parseCacheableAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, Cacheable cacheable) {
    CacheableOperation.Builder builder = new CacheableOperation.Builder();
    builder.setName(ae.toString());
    builder.setCacheNames(cacheable.cacheNames());
    builder.setCondition(cacheable.condition());
    builder.setUnless(cacheable.unless());
    builder.setKey(cacheable.key());
    builder.setKeyGenerator(cacheable.keyGenerator());
    builder.setCacheManager(cacheable.cacheManager());
    builder.setCacheResolver(cacheable.cacheResolver());
    builder.setSync(cacheable.sync());
    defaultConfig.applyDefault(builder);
    CacheableOperation op = builder.build();
    validateCacheOperation(ae, op);
    return op;
}
Also used : CacheableOperation(org.springframework.cache.interceptor.CacheableOperation)

Aggregations

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