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

@@ -52,34 +52,35 @@ public class RepositoryConfigurationExtensionSupportUnitTests {
assertThat(extension.isStrictRepositoryCandidate(AnnotatedTypeRepository.class), is(true));
}
/**
* @see DATACMNS-526
*/
@Test
public void considersRepositoryInterfaceExtendingStoreInterfaceStrictMatch() {
assertThat(extension.isStrictRepositoryCandidate(ExtendingInterface.class), is(true));
}
static class SampleRepositoryConfigurationExtension extends RepositoryConfigurationExtensionSupport {
/*
* (non-Javadoc)
* @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#getModulePrefix()
*/
@Override
protected String getModulePrefix() {
return "core";
}
/*
* (non-Javadoc)
* @see org.springframework.data.repository.config.RepositoryConfigurationExtension#getRepositoryFactoryClassName()
*/
@Override
public String getRepositoryFactoryClassName() {
return RepositoryFactorySupport.class.getName();
}
/*
* (non-Javadoc)
* @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#getIdentifyingAnnotations()
*/
@Override
protected Collection<Class<? extends Annotation>> getIdentifyingAnnotations() {
return Collections.<Class<? extends Annotation>> singleton(Primary.class);
}
@Override
protected Collection<Class<?>> getIdentifyingTypes() {
return Collections.<Class<?>> singleton(StoreInterface.class);
}
}
@Primary
@@ -90,4 +91,8 @@ public class RepositoryConfigurationExtensionSupportUnitTests {
interface AnnotatedTypeRepository extends Repository<AnnotatedType, Long> {}
interface PlainTypeRepository extends Repository<PlainType, Long> {}
interface StoreInterface {}
interface ExtendingInterface extends StoreInterface, Repository<PlainType, Long> {}
}