|
1 | 1 | package org.springframework.data.repository.config;
|
2 | 2 |
|
3 | 3 | import java.io.IOException;
|
4 |
| -import java.lang.annotation.Annotation; |
5 |
| -import java.lang.annotation.Inherited; |
6 | 4 | import java.util.ArrayList;
|
7 | 5 | import java.util.List;
|
8 | 6 |
|
9 | 7 | import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
|
10 | 8 | import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
11 |
| -import org.springframework.core.type.AnnotationMetadata; |
12 | 9 | import org.springframework.core.type.classreading.MetadataReader;
|
13 | 10 | import org.springframework.core.type.classreading.MetadataReaderFactory;
|
14 |
| -import org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter; |
| 11 | +import org.springframework.core.type.filter.AnnotationTypeFilter; |
15 | 12 | import org.springframework.core.type.filter.AssignableTypeFilter;
|
16 | 13 | import org.springframework.core.type.filter.TypeFilter;
|
17 | 14 | import org.springframework.data.repository.NoRepositoryBean;
|
@@ -117,82 +114,6 @@ public boolean match(MetadataReader metadataReader, MetadataReaderFactory metada
|
117 | 114 | }
|
118 | 115 | }
|
119 | 116 |
|
120 |
| - // Copy of Spring's AnnotationTypeFilter until SPR-8336 gets resolved. |
121 |
| - |
122 |
| - /** |
123 |
| - * A simple filter which matches classes with a given annotation, checking inherited annotations as well. |
124 |
| - * <p> |
125 |
| - * The matching logic mirrors that of <code>Class.isAnnotationPresent()</code>. |
126 |
| - * |
127 |
| - * @author Mark Fisher |
128 |
| - * @author Ramnivas Laddad |
129 |
| - * @author Juergen Hoeller |
130 |
| - * @since 2.5 |
131 |
| - */ |
132 |
| - private static class AnnotationTypeFilter extends AbstractTypeHierarchyTraversingFilter { |
133 |
| - |
134 |
| - private final Class<? extends Annotation> annotationType; |
135 |
| - |
136 |
| - private final boolean considerMetaAnnotations; |
137 |
| - |
138 |
| - /** |
139 |
| - * Create a new AnnotationTypeFilter for the given annotation type. This filter will also match meta-annotations. To |
140 |
| - * disable the meta-annotation matching, use the constructor that accepts a ' <code>considerMetaAnnotations</code>' |
141 |
| - * argument. The filter will not match interfaces. |
142 |
| - * |
143 |
| - * @param annotationType the annotation type to match |
144 |
| - */ |
145 |
| - public AnnotationTypeFilter(Class<? extends Annotation> annotationType) { |
146 |
| - this(annotationType, true); |
147 |
| - } |
148 |
| - |
149 |
| - /** |
150 |
| - * Create a new AnnotationTypeFilter for the given annotation type. The filter will not match interfaces. |
151 |
| - * |
152 |
| - * @param annotationType the annotation type to match |
153 |
| - * @param considerMetaAnnotations whether to also match on meta-annotations |
154 |
| - */ |
155 |
| - public AnnotationTypeFilter(Class<? extends Annotation> annotationType, boolean considerMetaAnnotations) { |
156 |
| - this(annotationType, considerMetaAnnotations, false); |
157 |
| - } |
158 |
| - |
159 |
| - /** |
160 |
| - * Create a new {@link AnnotationTypeFilter} for the given annotation type. |
161 |
| - * |
162 |
| - * @param annotationType the annotation type to match |
163 |
| - * @param considerMetaAnnotations whether to also match on meta-annotations |
164 |
| - * @param considerInterfaces whether to also match interfaces |
165 |
| - */ |
166 |
| - public AnnotationTypeFilter(Class<? extends Annotation> annotationType, boolean considerMetaAnnotations, |
167 |
| - boolean considerInterfaces) { |
168 |
| - super(annotationType.isAnnotationPresent(Inherited.class), considerInterfaces); |
169 |
| - this.annotationType = annotationType; |
170 |
| - this.considerMetaAnnotations = considerMetaAnnotations; |
171 |
| - } |
172 |
| - |
173 |
| - @Override |
174 |
| - protected boolean matchSelf(MetadataReader metadataReader) { |
175 |
| - AnnotationMetadata metadata = metadataReader.getAnnotationMetadata(); |
176 |
| - return metadata.hasAnnotation(this.annotationType.getName()) |
177 |
| - || (this.considerMetaAnnotations && metadata.hasMetaAnnotation(this.annotationType.getName())); |
178 |
| - } |
179 |
| - |
180 |
| - @Override |
181 |
| - protected Boolean matchSuperClass(String superClassName) { |
182 |
| - if (Object.class.getName().equals(superClassName)) { |
183 |
| - return Boolean.FALSE; |
184 |
| - } else if (superClassName.startsWith("java.")) { |
185 |
| - try { |
186 |
| - Class<?> clazz = getClass().getClassLoader().loadClass(superClassName); |
187 |
| - return (clazz.getAnnotation(this.annotationType) != null); |
188 |
| - } catch (ClassNotFoundException ex) { |
189 |
| - // Class not found - can't determine a match that way. |
190 |
| - } |
191 |
| - } |
192 |
| - return null; |
193 |
| - } |
194 |
| - } |
195 |
| - |
196 | 117 | /**
|
197 | 118 | * Helper class to create a {@link TypeFilter} that matches if all the delegates match.
|
198 | 119 | *
|
|
0 commit comments