@Scope annotations not sufficient for scanning anymore

This commit is contained in:
Juergen Hoeller 2009-09-15 12:36:45 +00:00
parent e1a3e44485
commit ad1269622b
3 changed files with 6 additions and 4 deletions

View File

@ -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.

View File

@ -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 {
}

View File

@ -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 {
}
@Component
@Scope("singleton")
public static class SingletonScopedTestBean extends ScopedTestBean {
}
@ -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 {
}