DATACMNS-1172 - Polishing.
Tweaked newly introduced RepositoryConfiguration.getImplementationBasePackage() to not require a parameter but use internal information instead (the repository interface in DefaultRepositoryConfiguration). Original pull request: #248.
This commit is contained in:
@@ -81,7 +81,7 @@ public class CustomRepositoryImplementationDetector {
|
||||
// TODO 2.0: Extract into dedicated interface for custom implementation lookup configuration.
|
||||
|
||||
return detectCustomImplementation(configuration.getImplementationClassName(), //
|
||||
configuration.getImplementationBasePackages(configuration.getRepositoryInterface()), //
|
||||
configuration.getImplementationBasePackages(), //
|
||||
configuration.getExcludeFilters());
|
||||
}
|
||||
|
||||
|
||||
@@ -83,11 +83,11 @@ public class DefaultRepositoryConfiguration<T extends RepositoryConfigurationSou
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.config.RepositoryConfiguration#getBasePackages(String)
|
||||
* @see org.springframework.data.repository.config.RepositoryConfiguration#getImplementationBasePackages()
|
||||
*/
|
||||
@Override
|
||||
public Iterable<String> getImplementationBasePackages(String interfaceClassName) {
|
||||
return Collections.singleton(ClassUtils.getPackageName(interfaceClassName));
|
||||
public Iterable<String> getImplementationBasePackages() {
|
||||
return Collections.singleton(ClassUtils.getPackageName(getRepositoryInterface()));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -40,7 +40,7 @@ public interface RepositoryConfiguration<T extends RepositoryConfigurationSource
|
||||
* @return
|
||||
* @since 1.13.8
|
||||
*/
|
||||
Iterable<String> getImplementationBasePackages(String interfaceClassName);
|
||||
Iterable<String> getImplementationBasePackages();
|
||||
|
||||
/**
|
||||
* Returns the interface name of the repository.
|
||||
|
||||
@@ -54,7 +54,7 @@ public class DefaultRepositoryConfigurationUnitTests {
|
||||
@Test // DATACMNS-1172
|
||||
public void limitsImplementationBasePackages() {
|
||||
|
||||
Iterable<String> packages = getConfiguration(source).getImplementationBasePackages("com.acme.MyRepository");
|
||||
Iterable<String> packages = getConfiguration(source, "com.acme.MyRepository").getImplementationBasePackages();
|
||||
|
||||
assertThat(packages, hasItem("com.acme"));
|
||||
}
|
||||
@@ -62,20 +62,22 @@ public class DefaultRepositoryConfigurationUnitTests {
|
||||
@Test // DATACMNS-1172
|
||||
public void limitsImplementationBasePackagesOfNestedClass() {
|
||||
|
||||
Iterable<String> packages = getConfiguration(source).getImplementationBasePackages(NestedInterface.class.getName());
|
||||
Iterable<String> packages = getConfiguration(source, MyRepository.class.getName()).getImplementationBasePackages();
|
||||
|
||||
assertThat(packages, hasItem("org.springframework.data.repository.config"));
|
||||
}
|
||||
|
||||
private DefaultRepositoryConfiguration<RepositoryConfigurationSource> getConfiguration(
|
||||
RepositoryConfigurationSource source) {
|
||||
RootBeanDefinition beanDefinition = createBeanDefinition();
|
||||
RepositoryConfigurationSource source, String repositoryInterfaceName) {
|
||||
|
||||
RootBeanDefinition beanDefinition = createBeanDefinition(repositoryInterfaceName);
|
||||
|
||||
return new DefaultRepositoryConfiguration<RepositoryConfigurationSource>(source, beanDefinition);
|
||||
}
|
||||
|
||||
private static RootBeanDefinition createBeanDefinition() {
|
||||
private static RootBeanDefinition createBeanDefinition(String repositoryInterfaceName) {
|
||||
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition("com.acme.MyRepository");
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(repositoryInterfaceName);
|
||||
|
||||
ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
|
||||
constructorArgumentValues.addGenericArgumentValue(MyRepository.class);
|
||||
|
||||
Reference in New Issue
Block a user