Browse Source

@Scope annotations not sufficient for scanning anymore

pull/23217/head
Juergen Hoeller 16 years ago
parent
commit
ad1269622b
  1. 3
      org.springframework.context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java
  2. 3
      org.springframework.integration-tests/src/test/java/org/springframework/context/annotation/jsr330/ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests.java
  3. 4
      org.springframework.integration-tests/src/test/java/org/springframework/context/annotation/scope/ClassPathBeanDefinitionScannerScopeIntegrationTests.java

3
org.springframework.context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java

@ -168,13 +168,10 @@ public class ClassPathScanningCandidateComponentProvider implements ResourceLoad @@ -168,13 +168,10 @@ public class ClassPathScanningCandidateComponentProvider implements ResourceLoad
@SuppressWarnings("unchecked")
protected void registerDefaultFilters() {
this.includeFilters.add(new AnnotationTypeFilter(Component.class));
this.includeFilters.add(new AnnotationTypeFilter(Scope.class));
ClassLoader cl = ClassPathScanningCandidateComponentProvider.class.getClassLoader();
try {
this.includeFilters.add(new AnnotationTypeFilter(
((Class<? extends Annotation>) cl.loadClass("javax.inject.Named"))));
this.includeFilters.add(new AnnotationTypeFilter(
((Class<? extends Annotation>) cl.loadClass("javax.inject.Scope"))));
}
catch (ClassNotFoundException ex) {
// JSR-330 API not available - simply skip.

3
org.springframework.integration-tests/src/test/java/org/springframework/context/annotation/jsr330/ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests.java

@ -366,12 +366,13 @@ public class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests { @@ -366,12 +366,13 @@ public class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@RequestScoped
@Named("request")
@RequestScoped
public static class RequestScopedTestBean extends ScopedTestBean implements AnotherScopeTestInterface {
}
@Named
@SessionScoped
public static class SessionScopedTestBean extends ScopedTestBean implements AnotherScopeTestInterface {
}

4
org.springframework.integration-tests/src/test/java/org/springframework/context/annotation/scope/ClassPathBeanDefinitionScannerScopeIntegrationTests.java

@ -36,6 +36,7 @@ import org.springframework.util.ClassUtils; @@ -36,6 +36,7 @@ import org.springframework.util.ClassUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.stereotype.Component;
/**
* @author Mark Fisher
@ -318,6 +319,7 @@ public class ClassPathBeanDefinitionScannerScopeIntegrationTests { @@ -318,6 +319,7 @@ public class ClassPathBeanDefinitionScannerScopeIntegrationTests {
}
@Component
@Scope("singleton")
public static class SingletonScopedTestBean extends ScopedTestBean {
}
@ -327,11 +329,13 @@ public class ClassPathBeanDefinitionScannerScopeIntegrationTests { @@ -327,11 +329,13 @@ public class ClassPathBeanDefinitionScannerScopeIntegrationTests {
}
@Component
@Scope("request")
public static class RequestScopedTestBean extends ScopedTestBean implements AnotherScopeTestInterface {
}
@Component
@Scope("session")
public static class SessionScopedTestBean extends ScopedTestBean implements AnotherScopeTestInterface {
}

Loading…
Cancel
Save