DATACMNS-1174 - Reject reactive repository implementation by default.

We now reject reactive repository metadata by RepositoryConfigurationExtensionSupport.useRepositoryConfiguration(…) assuming that Spring Data modules provide only imperative repository support by default. Reactive store modules are required to override useRepositoryConfiguration(…) anyway to not accidentally implement imperative repositories with a reactive Repository extension.
This commit is contained in:
Mark Paluch
2018-08-01 13:53:00 +02:00
committed by Oliver Gierke
parent 8e7a27cc72
commit ee64225be0
2 changed files with 47 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.io.ResourceLoader;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.core.support.AbstractRepositoryMetadata;
import org.springframework.util.Assert;
@@ -372,12 +373,23 @@ public abstract class RepositoryConfigurationExtensionSupport implements Reposit
}
/**
* Return whether to use the configuration for the repository with the given metadata. Defaults to {@literal true}.
* Return whether to use the configuration for the repository with the given metadata. Defaults to {@literal true} and
* {@link InvalidDataAccessApiUsageException} for {@link RepositoryMetadata#isReactiveRepository() reactive
* repositories}. Must be overridden by store modules that wish to provide reactive repositories.
*
* @param metadata will never be {@literal null}.
* @throws InvalidDataAccessApiUsageException on {@link RepositoryMetadata#isReactiveRepository() repositories} by
* default.
* @return
*/
protected boolean useRepositoryConfiguration(RepositoryMetadata metadata) {
if (metadata.isReactiveRepository()) {
throw new InvalidDataAccessApiUsageException(
String.format("Reactive Repositories are not supported by %s. Offending repository is %s!", getModuleName(),
metadata.getRepositoryInterface().getName()));
}
return true;
}