Polishing
This commit is contained in:
parent
d003f6614b
commit
6d6cf01a42
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -322,7 +322,7 @@ class PostProcessorRegistrationDelegate {
|
||||||
if (bean != null && !(bean instanceof BeanPostProcessor) && !isInfrastructureBean(beanName) &&
|
if (bean != null && !(bean instanceof BeanPostProcessor) && !isInfrastructureBean(beanName) &&
|
||||||
this.beanFactory.getBeanPostProcessorCount() < this.beanPostProcessorTargetCount) {
|
this.beanFactory.getBeanPostProcessorCount() < this.beanPostProcessorTargetCount) {
|
||||||
if (logger.isInfoEnabled()) {
|
if (logger.isInfoEnabled()) {
|
||||||
logger.info("Bean '" + beanName + "' of type [" + bean.getClass() +
|
logger.info("Bean '" + beanName + "' of type [" + bean.getClass().getName() +
|
||||||
"] is not eligible for getting processed by all BeanPostProcessors " +
|
"] is not eligible for getting processed by all BeanPostProcessors " +
|
||||||
"(for example: not eligible for auto-proxying)");
|
"(for example: not eligible for auto-proxying)");
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ class PostProcessorRegistrationDelegate {
|
||||||
private boolean isInfrastructureBean(String beanName) {
|
private boolean isInfrastructureBean(String beanName) {
|
||||||
if (beanName != null && this.beanFactory.containsBeanDefinition(beanName)) {
|
if (beanName != null && this.beanFactory.containsBeanDefinition(beanName)) {
|
||||||
BeanDefinition bd = this.beanFactory.getBeanDefinition(beanName);
|
BeanDefinition bd = this.beanFactory.getBeanDefinition(beanName);
|
||||||
return RootBeanDefinition.ROLE_INFRASTRUCTURE == bd.getRole();
|
return (bd.getRole() == RootBeanDefinition.ROLE_INFRASTRUCTURE);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -159,11 +159,12 @@ public class AsyncAnnotationAdvisor extends AbstractPointcutAdvisor implements B
|
||||||
Pointcut cpc = new AnnotationMatchingPointcut(asyncAnnotationType, true);
|
Pointcut cpc = new AnnotationMatchingPointcut(asyncAnnotationType, true);
|
||||||
Pointcut mpc = AnnotationMatchingPointcut.forMethodAnnotation(asyncAnnotationType);
|
Pointcut mpc = AnnotationMatchingPointcut.forMethodAnnotation(asyncAnnotationType);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = new ComposablePointcut(cpc).union(mpc);
|
result = new ComposablePointcut(cpc);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result.union(cpc).union(mpc);
|
result.union(cpc);
|
||||||
}
|
}
|
||||||
|
result = result.union(mpc);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
package org.springframework.cache.config;
|
package org.springframework.cache.config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic service interface.
|
* Basic service interface for caching tests.
|
||||||
*
|
*
|
||||||
* @author Costin Leau
|
* @author Costin Leau
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
@ -83,7 +83,6 @@ public interface CacheableService<T> {
|
||||||
|
|
||||||
T throwUncheckedSync(Object arg1);
|
T throwUncheckedSync(Object arg1);
|
||||||
|
|
||||||
// multi annotations
|
|
||||||
T multiCache(Object arg1);
|
T multiCache(Object arg1);
|
||||||
|
|
||||||
T multiEvict(Object arg1);
|
T multiEvict(Object arg1);
|
||||||
|
@ -95,4 +94,5 @@ public interface CacheableService<T> {
|
||||||
T multiUpdate(Object arg1);
|
T multiUpdate(Object arg1);
|
||||||
|
|
||||||
TestEntity putRefersToResult(TestEntity arg1);
|
TestEntity putRefersToResult(TestEntity arg1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -25,7 +25,7 @@ import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple cacheable service
|
* Simple cacheable service.
|
||||||
*
|
*
|
||||||
* @author Costin Leau
|
* @author Costin Leau
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
@ -34,8 +34,10 @@ import org.springframework.cache.annotation.Caching;
|
||||||
public class DefaultCacheableService implements CacheableService<Long> {
|
public class DefaultCacheableService implements CacheableService<Long> {
|
||||||
|
|
||||||
private final AtomicLong counter = new AtomicLong();
|
private final AtomicLong counter = new AtomicLong();
|
||||||
|
|
||||||
private final AtomicLong nullInvocations = new AtomicLong();
|
private final AtomicLong nullInvocations = new AtomicLong();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable("testCache")
|
@Cacheable("testCache")
|
||||||
public Long cache(Object arg1) {
|
public Long cache(Object arg1) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -65,8 +65,6 @@ public class EnableCachingTests extends AbstractCacheAnnotationTests {
|
||||||
assertSame(this.ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
|
assertSame(this.ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- local tests -------
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void singleCacheManagerBean() throws Throwable {
|
public void singleCacheManagerBean() throws Throwable {
|
||||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||||
|
@ -92,7 +90,7 @@ public class EnableCachingTests extends AbstractCacheAnnotationTests {
|
||||||
public void multipleCacheManagerBeans_implementsCachingConfigurer() {
|
public void multipleCacheManagerBeans_implementsCachingConfigurer() {
|
||||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||||
ctx.register(MultiCacheManagerConfigurer.class);
|
ctx.register(MultiCacheManagerConfigurer.class);
|
||||||
ctx.refresh(); // does not throw
|
ctx.refresh(); // does not throw an exception
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalStateException.class)
|
@Test(expected = IllegalStateException.class)
|
||||||
|
@ -125,22 +123,17 @@ public class EnableCachingTests extends AbstractCacheAnnotationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void emptyConfigSupport() {
|
public void emptyConfigSupport() {
|
||||||
ConfigurableApplicationContext context =
|
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class);
|
||||||
new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class);
|
|
||||||
|
|
||||||
CacheInterceptor ci = context.getBean(CacheInterceptor.class);
|
CacheInterceptor ci = context.getBean(CacheInterceptor.class);
|
||||||
assertNotNull(ci.getCacheResolver());
|
assertNotNull(ci.getCacheResolver());
|
||||||
assertEquals(SimpleCacheResolver.class, ci.getCacheResolver().getClass());
|
assertEquals(SimpleCacheResolver.class, ci.getCacheResolver().getClass());
|
||||||
assertSame(context.getBean(CacheManager.class),
|
assertSame(context.getBean(CacheManager.class), ((SimpleCacheResolver)ci.getCacheResolver()).getCacheManager());
|
||||||
((SimpleCacheResolver)ci.getCacheResolver()).getCacheManager());
|
|
||||||
context.close();
|
context.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bothSetOnlyResolverIsUsed() {
|
public void bothSetOnlyResolverIsUsed() {
|
||||||
ConfigurableApplicationContext context =
|
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(FullCachingConfig.class);
|
||||||
new AnnotationConfigApplicationContext(FullCachingConfig.class);
|
|
||||||
|
|
||||||
CacheInterceptor ci = context.getBean(CacheInterceptor.class);
|
CacheInterceptor ci = context.getBean(CacheInterceptor.class);
|
||||||
assertSame(context.getBean("cacheResolver"), ci.getCacheResolver());
|
assertSame(context.getBean("cacheResolver"), ci.getCacheResolver());
|
||||||
assertSame(context.getBean("keyGenerator"), ci.getKeyGenerator());
|
assertSame(context.getBean("keyGenerator"), ci.getKeyGenerator());
|
||||||
|
|
Loading…
Reference in New Issue