Browse Source

considerInterfaces should work without considerInherited as well

Issue: SPR-11719
pull/529/head
Juergen Hoeller 12 years ago
parent
commit
5ab7076118
  1. 60
      spring-core/src/main/java/org/springframework/core/type/filter/AbstractTypeHierarchyTraversingFilter.java

60
spring-core/src/main/java/org/springframework/core/type/filter/AbstractTypeHierarchyTraversingFilter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,8 +19,8 @@ package org.springframework.core.type.filter;
import java.io.IOException; import java.io.IOException;
import org.springframework.core.type.ClassMetadata; import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
/** /**
* Type filter that is aware of traversing over hierarchy. * Type filter that is aware of traversing over hierarchy.
@ -61,40 +61,38 @@ public abstract class AbstractTypeHierarchyTraversingFilter implements TypeFilte
return true; return true;
} }
if (!this.considerInherited) { if (this.considerInherited) {
return false; if (metadata.hasSuperClass()) {
} // Optimization to avoid creating ClassReader for super class.
if (metadata.hasSuperClass()) { Boolean superClassMatch = matchSuperClass(metadata.getSuperClassName());
// Optimization to avoid creating ClassReader for super class. if (superClassMatch != null) {
Boolean superClassMatch = matchSuperClass(metadata.getSuperClassName()); if (superClassMatch.booleanValue()) {
if (superClassMatch != null) { return true;
if (superClassMatch.booleanValue()) { }
return true;
} }
} else {
else { // Need to read super class to determine a match...
// Need to read super class to determine a match... if (match(metadata.getSuperClassName(), metadataReaderFactory)) {
if (match(metadata.getSuperClassName(), metadataReaderFactory)) { return true;
return true; }
} }
} }
} }
if (!this.considerInterfaces) { if (this.considerInterfaces) {
return false; for (String ifc : metadata.getInterfaceNames()) {
} // Optimization to avoid creating ClassReader for super class
for (String ifc : metadata.getInterfaceNames()) { Boolean interfaceMatch = matchInterface(ifc);
// Optimization to avoid creating ClassReader for super class if (interfaceMatch != null) {
Boolean interfaceMatch = matchInterface(ifc); if (interfaceMatch.booleanValue()) {
if (interfaceMatch != null) { return true;
if (interfaceMatch.booleanValue()) { }
return true;
} }
} else {
else { // Need to read interface to determine a match...
// Need to read interface to determine a match... if (match(ifc, metadataReaderFactory)) {
if (match(ifc, metadataReaderFactory)) { return true;
return true; }
} }
} }
} }
@ -132,7 +130,7 @@ public abstract class AbstractTypeHierarchyTraversingFilter implements TypeFilte
/** /**
* Override this to match on interface type name. * Override this to match on interface type name.
*/ */
protected Boolean matchInterface(String interfaceNames) { protected Boolean matchInterface(String interfaceName) {
return null; return null;
} }

Loading…
Cancel
Save