use of org.springframework.cache.jcache.interceptor.JCacheInterceptor in project spring-framework by spring-projects.
the class ProxyJCacheConfiguration method cacheInterceptor.
@Bean(name = "jCacheInterceptor")
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public JCacheInterceptor cacheInterceptor() {
JCacheInterceptor interceptor = new JCacheInterceptor();
interceptor.setCacheOperationSource(cacheOperationSource());
if (this.errorHandler != null) {
interceptor.setErrorHandler(this.errorHandler);
}
return interceptor;
}
use of org.springframework.cache.jcache.interceptor.JCacheInterceptor in project spring-framework by spring-projects.
the class JCacheJavaConfigTests method fullCachingConfig.
@Test
public void fullCachingConfig() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(FullCachingConfig.class);
DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class);
assertSame(context.getBean(KeyGenerator.class), cos.getKeyGenerator());
assertSame(context.getBean("cacheResolver", CacheResolver.class), cos.getCacheResolver());
assertSame(context.getBean("exceptionCacheResolver", CacheResolver.class), cos.getExceptionCacheResolver());
JCacheInterceptor interceptor = context.getBean(JCacheInterceptor.class);
assertSame(context.getBean("errorHandler", CacheErrorHandler.class), interceptor.getErrorHandler());
}
use of org.springframework.cache.jcache.interceptor.JCacheInterceptor in project spring-framework by spring-projects.
the class JCacheNamespaceDrivenTests method testCacheErrorHandler.
@Test
public void testCacheErrorHandler() {
JCacheInterceptor ci = ctx.getBean(JCacheInterceptor.class);
assertSame(ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
}
use of org.springframework.cache.jcache.interceptor.JCacheInterceptor in project spring-framework by spring-projects.
the class JCacheCustomInterceptorTests method onlyOneInterceptorIsAvailable.
@Test
public void onlyOneInterceptorIsAvailable() {
Map<String, JCacheInterceptor> interceptors = ctx.getBeansOfType(JCacheInterceptor.class);
assertEquals("Only one interceptor should be defined", 1, interceptors.size());
JCacheInterceptor interceptor = interceptors.values().iterator().next();
assertEquals("Custom interceptor not defined", TestCacheInterceptor.class, interceptor.getClass());
}
Aggregations