类org.springframework.cache.interceptor.CacheErrorHandler源码实例Demo

下面列出了怎么用org.springframework.cache.interceptor.CacheErrorHandler的API类实例代码及写法,或者点击链接到github查看源代码。

@Before
public void setup() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
	this.cache = context.getBean("mockCache", Cache.class);
	this.errorCache = context.getBean("mockErrorCache", Cache.class);
	this.errorHandler = context.getBean(CacheErrorHandler.class);
	this.simpleService = context.getBean(SimpleService.class);
}
 
@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());
}
 
@Before
public void setup() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
	this.cache = context.getBean("mockCache", Cache.class);
	this.errorCache = context.getBean("mockErrorCache", Cache.class);
	this.errorHandler = context.getBean(CacheErrorHandler.class);
	this.simpleService = context.getBean(SimpleService.class);
}
 
@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());
}
 
@Before
public void setup() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
	this.cache = context.getBean("mockCache", Cache.class);
	this.errorHandler = context.getBean(CacheErrorHandler.class);
	this.simpleService = context.getBean(SimpleService.class);
}
 
@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());
}
 
@Override
@Nullable
public CacheErrorHandler errorHandler() {
	return null;
}
 
@Test
public void testCacheErrorHandler() {
	CacheInterceptor ci = this.ctx.getBean(
			"org.springframework.cache.interceptor.CacheInterceptor#0", CacheInterceptor.class);
	assertSame(this.ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
}
 
源代码9 项目: spring-analysis-note   文件: EnableCachingTests.java
@Test
public void testCacheErrorHandler() {
	CacheInterceptor ci = this.ctx.getBean(CacheInterceptor.class);
	assertSame(this.ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
}
 
源代码10 项目: spring-analysis-note   文件: EnableCachingTests.java
@Override
@Bean
public CacheErrorHandler errorHandler() {
	return new SimpleCacheErrorHandler();
}
 
protected AbstractCacheInterceptor(CacheErrorHandler errorHandler) {
	super(errorHandler);
}
 
public CacheResultInterceptor(CacheErrorHandler errorHandler) {
	super(errorHandler);
}
 
protected CacheRemoveEntryInterceptor(CacheErrorHandler errorHandler) {
	super(errorHandler);
}
 
protected AbstractKeyCacheInterceptor(CacheErrorHandler errorHandler) {
	super(errorHandler);
}
 
protected CacheRemoveAllInterceptor(CacheErrorHandler errorHandler) {
	super(errorHandler);
}
 
源代码16 项目: spring-analysis-note   文件: CachePutInterceptor.java
public CachePutInterceptor(CacheErrorHandler errorHandler) {
	super(errorHandler);
}
 
@Bean
@Override
public CacheErrorHandler errorHandler() {
	return mock(CacheErrorHandler.class);
}
 
@Override
@Bean
public CacheErrorHandler errorHandler() {
	return new SimpleCacheErrorHandler();
}
 
@Test
public void testCacheErrorHandler() {
	JCacheInterceptor ci = ctx.getBean(JCacheInterceptor.class);
	assertSame(ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
}
 
@Override
@Bean
public CacheErrorHandler errorHandler() {
	return new SimpleCacheErrorHandler();
}
 
@Test
public void testCacheErrorHandler() {
	load(EnableCachingConfig.class);
	AnnotationCacheAspect aspect = this.ctx.getBean(AnnotationCacheAspect.class);
	assertSame(this.ctx.getBean("errorHandler", CacheErrorHandler.class), aspect.getErrorHandler());
}
 
@Override
@Bean
public CacheErrorHandler errorHandler() {
	return new SimpleCacheErrorHandler();
}
 
源代码23 项目: hellokoding-courses   文件: CachingConfiguration.java
@Override
public CacheErrorHandler errorHandler() {
    return new CustomCacheErrorHandler();
}
 
@Override
@Nullable
public CacheErrorHandler errorHandler() {
	return null;
}
 
@Test
public void testCacheErrorHandler() {
	CacheInterceptor ci = this.ctx.getBean(
			"org.springframework.cache.interceptor.CacheInterceptor#0", CacheInterceptor.class);
	assertSame(this.ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
}
 
源代码26 项目: java-technology-stack   文件: EnableCachingTests.java
@Test
public void testCacheErrorHandler() {
	CacheInterceptor ci = this.ctx.getBean(CacheInterceptor.class);
	assertSame(this.ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
}
 
源代码27 项目: java-technology-stack   文件: EnableCachingTests.java
@Override
@Bean
public CacheErrorHandler errorHandler() {
	return new SimpleCacheErrorHandler();
}
 
protected AbstractCacheInterceptor(CacheErrorHandler errorHandler) {
	super(errorHandler);
}
 
public CacheResultInterceptor(CacheErrorHandler errorHandler) {
	super(errorHandler);
}
 
protected CacheRemoveEntryInterceptor(CacheErrorHandler errorHandler) {
	super(errorHandler);
}
 
 类方法
 同包方法