DATACMNS-526 - Added type matching to strict repository scanning.

Repository interfaces are now also considered strict matches if they are assignable to one of the types returned by getIdentifyingTypes().
This commit is contained in:
Oliver Gierke
2014-07-29 14:18:41 +02:00
parent 81af5ee730
commit 85157b6644
2 changed files with 36 additions and 13 deletions

View File

@@ -157,6 +157,16 @@ public abstract class RepositoryConfigurationExtensionSupport implements Reposit
return Collections.emptySet();
}
/**
* Returns the types that indicate a store match when inspecting repositories for strict matches.
*
* @return
* @since 1.9
*/
protected Collection<Class<?>> getIdentifyingTypes() {
return Collections.emptySet();
}
/**
* Sets the given source on the given {@link AbstractBeanDefinition} and registers it inside the given
* {@link BeanDefinitionRegistry}.
@@ -219,8 +229,16 @@ public abstract class RepositoryConfigurationExtensionSupport implements Reposit
protected boolean isStrictRepositoryCandidate(Class<?> repositoryInterface) {
RepositoryMetadata metadata = AbstractRepositoryMetadata.getMetadata(repositoryInterface);
Class<?> domainType = metadata.getDomainType();
Collection<Class<?>> types = getIdentifyingTypes();
for (Class<?> type : types) {
if (type.isAssignableFrom(repositoryInterface)) {
return true;
}
}
Class<?> domainType = metadata.getDomainType();
Collection<Class<? extends Annotation>> annotations = getIdentifyingAnnotations();
if (annotations.isEmpty()) {