From cee7479cd09c52a7f81640b7453b08a65b5bfdf2 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 20 Jun 2018 16:59:45 +0200 Subject: [PATCH] #2 - Exclude reactive repositories from JdbcRepositoryConfigExtension. --- .../config/JdbcRepositoryConfigExtension.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/main/java/org/springframework/data/jdbc/repository/config/JdbcRepositoryConfigExtension.java diff --git a/src/main/java/org/springframework/data/jdbc/repository/config/JdbcRepositoryConfigExtension.java b/src/main/java/org/springframework/data/jdbc/repository/config/JdbcRepositoryConfigExtension.java new file mode 100644 index 0000000..fcac316 --- /dev/null +++ b/src/main/java/org/springframework/data/jdbc/repository/config/JdbcRepositoryConfigExtension.java @@ -0,0 +1,68 @@ +/* + * Copyright 2017-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.data.jdbc.repository.config; + +import java.util.Locale; + +import org.springframework.data.jdbc.repository.support.JdbcRepositoryFactoryBean; +import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport; +import org.springframework.data.repository.core.RepositoryMetadata; + +/** + * {@link org.springframework.data.repository.config.RepositoryConfigurationExtension} extending the repository + * registration process by registering JDBC repositories. + * + * @author Jens Schauder + * @author Mark Paluch + */ +public class JdbcRepositoryConfigExtension extends RepositoryConfigurationExtensionSupport { + + /* + * (non-Javadoc) + * @see org.springframework.data.repository.config.RepositoryConfigurationExtension#getModuleName() + */ + @Override + public String getModuleName() { + return "JDBC"; + } + + /* + * (non-Javadoc) + * @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#getRepositoryFactoryBeanClassName() + */ + @Override + public String getRepositoryFactoryBeanClassName() { + return JdbcRepositoryFactoryBean.class.getName(); + } + + /* + * (non-Javadoc) + * @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#getModulePrefix() + */ + @Override + protected String getModulePrefix() { + return getModuleName().toLowerCase(Locale.US); + } + + /* + * (non-Javadoc) + * @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#useRepositoryConfiguration(org.springframework.data.repository.core.RepositoryMetadata) + */ + @Override + protected boolean useRepositoryConfiguration(RepositoryMetadata metadata) { + return !metadata.isReactiveRepository(); + } +}