DATACMNS-989 - Use exclude filters when scanning for custom repository implementations.
The detection algorithm for custom repository implementations now considers the exclude filters declared in the overall repository setup (XML and annotations). Original pull request: #195.
This commit is contained in:
committed by
Oliver Gierke
parent
f8715ac8a8
commit
3ca77831e1
@@ -18,6 +18,6 @@ package org.springframework.data.repository.config;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSourceUnitTests.Person;
|
||||
|
||||
interface MyOtherRepository extends Repository<Person, Long> {
|
||||
interface MyOtherRepository extends Repository<Person, Long>, MyOtherRepositoryExtensions {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.springframework.data.repository.config;
|
||||
|
||||
public interface MyOtherRepositoryExtensions {
|
||||
String getImplementationId();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.springframework.data.repository.config;
|
||||
|
||||
public class MyOtherRepositoryImpl implements MyOtherRepositoryExtensions {
|
||||
@Override
|
||||
public String getImplementationId() {
|
||||
return getClass().getName();
|
||||
}
|
||||
}
|
||||
@@ -23,18 +23,21 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupportUnitTests.DummyConfigurationExtension;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link RepositoryBeanDefinitionRegistrarSupport}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Peter Rietzler
|
||||
*/
|
||||
public class RepositoryBeanDefinitionRegistrarSupportIntegrationTests {
|
||||
|
||||
@Configuration
|
||||
@EnableRepositories
|
||||
@EnableRepositories(excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = ".*\\.excluded\\..*"))
|
||||
static class SampleConfig {
|
||||
|
||||
}
|
||||
@@ -59,6 +62,11 @@ public class RepositoryBeanDefinitionRegistrarSupportIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test // DATACMNS-989
|
||||
public void duplicateImplementationsMayBeExcludedViaFilters() {
|
||||
assertThat(context.getBean(MyOtherRepository.class).getImplementationId(), is(MyOtherRepositoryImpl.class.getName()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-47
|
||||
public void testBootstrappingWithInheritedConfigClasses() {
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.springframework.data.repository.config.excluded;
|
||||
|
||||
import org.springframework.data.repository.config.MyOtherRepositoryExtensions;
|
||||
|
||||
public class MyOtherRepositoryImpl implements MyOtherRepositoryExtensions {
|
||||
@Override
|
||||
public String getImplementationId() {
|
||||
return getClass().getName();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user