|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2012 the original author or authors. |
| 2 | + * Copyright 2002-2014 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
19 | 19 | import java.lang.annotation.Annotation;
|
20 | 20 | import java.lang.annotation.Inherited;
|
21 | 21 |
|
| 22 | +import org.springframework.core.annotation.AnnotationUtils; |
22 | 23 | import org.springframework.core.type.AnnotationMetadata;
|
23 | 24 | import org.springframework.core.type.classreading.MetadataReader;
|
24 | 25 |
|
@@ -49,7 +50,7 @@ public class AnnotationTypeFilter extends AbstractTypeHierarchyTraversingFilter
|
49 | 50 | * @param annotationType the annotation type to match
|
50 | 51 | */
|
51 | 52 | public AnnotationTypeFilter(Class<? extends Annotation> annotationType) {
|
52 |
| - this(annotationType, true); |
| 53 | + this(annotationType, true, false); |
53 | 54 | }
|
54 | 55 |
|
55 | 56 | /**
|
@@ -84,13 +85,23 @@ protected boolean matchSelf(MetadataReader metadataReader) {
|
84 | 85 |
|
85 | 86 | @Override
|
86 | 87 | protected Boolean matchSuperClass(String superClassName) {
|
87 |
| - if (Object.class.getName().equals(superClassName)) { |
88 |
| - return Boolean.FALSE; |
| 88 | + return hasAnnotation(superClassName); |
| 89 | + } |
| 90 | + |
| 91 | + @Override |
| 92 | + protected Boolean matchInterface(String interfaceName) { |
| 93 | + return hasAnnotation(interfaceName); |
| 94 | + } |
| 95 | + |
| 96 | + protected Boolean hasAnnotation(String typeName) { |
| 97 | + if (Object.class.getName().equals(typeName)) { |
| 98 | + return false; |
89 | 99 | }
|
90 |
| - else if (superClassName.startsWith("java.")) { |
| 100 | + else if (typeName.startsWith("java.")) { |
91 | 101 | try {
|
92 |
| - Class<?> clazz = getClass().getClassLoader().loadClass(superClassName); |
93 |
| - return (clazz.getAnnotation(this.annotationType) != null); |
| 102 | + Class<?> clazz = getClass().getClassLoader().loadClass(typeName); |
| 103 | + return ((this.considerMetaAnnotations ? AnnotationUtils.getAnnotation(clazz, this.annotationType) : |
| 104 | + clazz.getAnnotation(this.annotationType)) != null); |
94 | 105 | }
|
95 | 106 | catch (ClassNotFoundException ex) {
|
96 | 107 | // Class not found - can't determine a match that way.
|
|
0 commit comments