org.springframework.cache.jcache.interceptor.JCacheInterceptor Java Examples

The following examples show how to use org.springframework.cache.jcache.interceptor.JCacheInterceptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JCacheJavaConfigTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example #2
Source File: JCacheCustomInterceptorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #3
Source File: JCacheJavaConfigTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #4
Source File: ProxyJCacheConfiguration.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #5
Source File: ProxyJCacheConfiguration.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example #6
Source File: ProxyJCacheConfigurationInitializer.java    From spring-init with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(GenericApplicationContext context) {
	context.registerBean(ProxyJCacheConfiguration.class, () -> new ProxyJCacheConfiguration());
	context.registerBean(BeanFactoryJCacheOperationSourceAdvisor.class,
			() -> context.getBean(ProxyJCacheConfiguration.class).cacheAdvisor(
					context.getBean(JCacheOperationSource.class), context.getBean(JCacheInterceptor.class)));
	context.registerBean(JCacheInterceptor.class, () -> context.getBean(ProxyJCacheConfiguration.class)
			.cacheInterceptor(context.getBean(JCacheOperationSource.class)));
	context.registerBean(JCacheOperationSource.class,
			() -> context.getBean(ProxyJCacheConfiguration.class).cacheOperationSource());
}
 
Example #7
Source File: JCacheCustomInterceptorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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());
}
 
Example #8
Source File: JCacheJavaConfigTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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());
}
 
Example #9
Source File: ProxyJCacheConfiguration.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Bean(name = "jCacheInterceptor")
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public JCacheInterceptor cacheInterceptor() {
	JCacheInterceptor interceptor = new JCacheInterceptor(this.errorHandler);
	interceptor.setCacheOperationSource(cacheOperationSource());
	return interceptor;
}
 
Example #10
Source File: JCacheCustomInterceptorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example #11
Source File: ProxyJCacheConfiguration.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Bean(name = "jCacheInterceptor")
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public JCacheInterceptor cacheInterceptor() {
	JCacheInterceptor interceptor = new JCacheInterceptor(this.errorHandler);
	interceptor.setCacheOperationSource(cacheOperationSource());
	return interceptor;
}
 
Example #12
Source File: JCacheNamespaceDrivenTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test
public void testCacheErrorHandler() {
	JCacheInterceptor ci = ctx.getBean(JCacheInterceptor.class);
	assertSame(ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
}
 
Example #13
Source File: JCacheCustomInterceptorTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Bean
public JCacheInterceptor jCacheInterceptor(JCacheOperationSource cacheOperationSource) {
	JCacheInterceptor cacheInterceptor = new TestCacheInterceptor();
	cacheInterceptor.setCacheOperationSource(cacheOperationSource);
	return cacheInterceptor;
}
 
Example #14
Source File: JCacheCustomInterceptorTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Bean
public JCacheInterceptor jCacheInterceptor(JCacheOperationSource cacheOperationSource) {
	JCacheInterceptor cacheInterceptor = new TestCacheInterceptor();
	cacheInterceptor.setCacheOperationSource(cacheOperationSource);
	return cacheInterceptor;
}
 
Example #15
Source File: JCacheNamespaceDrivenTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test
public void testCacheErrorHandler() {
	JCacheInterceptor ci = ctx.getBean(JCacheInterceptor.class);
	assertSame(ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
}
 
Example #16
Source File: JCacheNamespaceDrivenTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void testCacheErrorHandler() {
	JCacheInterceptor ci = ctx.getBean(JCacheInterceptor.class);
	assertSame(ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
}
 
Example #17
Source File: JCacheCustomInterceptorTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
public JCacheInterceptor jCacheInterceptor(JCacheOperationSource cacheOperationSource) {
	JCacheInterceptor cacheInterceptor = new TestCacheInterceptor();
	cacheInterceptor.setCacheOperationSource(cacheOperationSource);
	return cacheInterceptor;
}