diff --git a/spring-cloud-config-client/src/main/java/org/springframework/cloud/context/scope/GenericScope.java b/spring-cloud-config-client/src/main/java/org/springframework/cloud/context/scope/GenericScope.java index 5dcce943..719be07e 100644 --- a/spring-cloud-config-client/src/main/java/org/springframework/cloud/context/scope/GenericScope.java +++ b/spring-cloud-config-client/src/main/java/org/springframework/cloud/context/scope/GenericScope.java @@ -38,16 +38,13 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.cloud.context.config.BeanLifecycleDecorator; import org.springframework.cloud.context.config.BeanLifecycleDecorator.Context; import org.springframework.cloud.context.config.StandardBeanLifecycleDecorator; -import org.springframework.context.annotation.Configuration; import org.springframework.context.expression.BeanFactoryAccessor; -import org.springframework.core.annotation.AnnotationUtils; import org.springframework.expression.Expression; import org.springframework.expression.ExpressionParser; import org.springframework.expression.ParseException; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.StandardEvaluationContext; import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; import org.springframework.util.StringValueResolver; @@ -336,27 +333,6 @@ public class GenericScope implements Scope, BeanFactoryPostProcessor, Disposable this.scoped = scoped; } - @Override - protected void visitBeanClassName(BeanDefinition beanDefinition) { - String className = beanDefinition.getBeanClassName(); - if (className!=null) { - Class type = ClassUtils.resolveClassName(className, null); - Assert.state( - !beanDefinition.getScope().equals(scope) - || AnnotationUtils.findAnnotation(type, - Configuration.class) == null, - "Scoped proxies not allowed on @Configuration (for '" + scope - + "' scope) on bean of type " + type); - org.springframework.context.annotation.Scope beanScope = AnnotationUtils - .findAnnotation(type, - org.springframework.context.annotation.Scope.class); - if (beanScope != null && !scoped && beanScope.value().equals(scope)) { - beanDefinition.setScope(scope); - } - } - super.visitBeanClassName(beanDefinition); - } - @Override protected Object resolveValue(Object value) { diff --git a/spring-cloud-config-client/src/test/java/org/springframework/cloud/context/scope/refresh/ImportRefreshScopeIntegrationTests.java b/spring-cloud-config-client/src/test/java/org/springframework/cloud/context/scope/refresh/ImportRefreshScopeIntegrationTests.java index c0e4500d..fbceb601 100644 --- a/spring-cloud-config-client/src/test/java/org/springframework/cloud/context/scope/refresh/ImportRefreshScopeIntegrationTests.java +++ b/spring-cloud-config-client/src/test/java/org/springframework/cloud/context/scope/refresh/ImportRefreshScopeIntegrationTests.java @@ -28,7 +28,6 @@ import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.context.scope.refresh.ImportRefreshScopeIntegrationTests.TestConfiguration; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @SpringApplicationConfiguration(classes = TestConfiguration.class) @@ -46,7 +45,6 @@ public class ImportRefreshScopeIntegrationTests { private org.springframework.cloud.context.scope.refresh.RefreshScope scope; @Test - @DirtiesContext public void testSimpleProperties() throws Exception { assertEquals("Hello scope!", service.getMessage()); assertEquals("refresh", beanFactory.getBeanDefinition("service").getScope()); diff --git a/spring-cloud-config-client/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationTests.java b/spring-cloud-config-client/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationTests.java index 51303e5f..24185e6d 100644 --- a/spring-cloud-config-client/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationTests.java +++ b/spring-cloud-config-client/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeConfigurationTests.java @@ -29,7 +29,6 @@ import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.context.environment.EnvironmentManager; import org.springframework.cloud.context.scope.refresh.RefreshScopeConfigurationTests.NestedApp.NestedController; -import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -42,7 +41,7 @@ import org.springframework.web.bind.annotation.RestController; */ public class RefreshScopeConfigurationTests { - private ConfigurableApplicationContext context; + private AnnotationConfigApplicationContext context; @Rule public ExpectedException expected = ExpectedException.none(); @@ -65,10 +64,16 @@ public class RefreshScopeConfigurationTests { * See gh-43 */ @Test + @Ignore("gh-43") public void configurationWithRefreshScope() throws Exception { - expected.expectMessage("Scoped proxies not allowed on @Configuration"); context = new AnnotationConfigApplicationContext(Application.class, PropertyPlaceholderAutoConfiguration.class, RefreshAutoConfiguration.class); + Application application = context.getBean(Application.class); + assertEquals("refresh", context.getBeanDefinition("application").getScope()); + application.hello(); + refresh(); + String message = application.hello(); + assertEquals("Hello Dave!", message); } @Test @@ -83,7 +88,6 @@ public class RefreshScopeConfigurationTests { } @Test - @Ignore("SPR-12486") public void refreshScopeOnNested() throws Exception { context = new AnnotationConfigApplicationContext(NestedApp.class, PropertyPlaceholderAutoConfiguration.class, RefreshAutoConfiguration.class); @@ -118,7 +122,7 @@ public class RefreshScopeConfigurationTests { } - @Configuration + @Configuration("application") @RefreshScope protected static class Application {