You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/02/09 21:18:31 UTC

[GitHub] [ignite-extensions] SammyVimes commented on a change in pull request #41: IGNITE-13029 Ignite Spring Data autoconfiguration

SammyVimes commented on a change in pull request #41:
URL: https://github.com/apache/ignite-extensions/pull/41#discussion_r573227698



##########
File path: modules/spring-boot-autoconfigure-ext/src/main/resources/META-INF/spring.factories
##########
@@ -14,4 +14,5 @@
 # limitations under the License.
 
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-org.apache.ignite.springframework.boot.autoconfigure.IgniteAutoConfiguration
+org.apache.ignite.springframework.boot.autoconfigure.IgniteAutoConfiguration,\
+org.apache.ignite.springframework.boot.autoconfigure.IgniteRepositoryAutoConfiguration

Review comment:
       Please add a newline here

##########
File path: modules/spring-boot-autoconfigure-ext/src/test/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteRepositoriesAutoconfigureTest.java
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.springframework.boot.autoconfigure;
+
+import org.apache.ignite.springdata22.repository.config.EnableIgniteRepositories;
+import org.apache.ignite.springframework.boot.autoconfigure.misc.DefaultTestConfigutation;
+import org.apache.ignite.springframework.boot.autoconfigure.misc.ObjectRepository;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
+import org.springframework.boot.autoconfigure.AutoConfigurations;
+import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests {@link IgniteRepositoryAutoConfiguration} feature. */
+@ExtendWith(SpringExtension.class)
+public class IgniteRepositoriesAutoconfigureTest {
+
+    /** Spring test application context. */
+    private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
+        .withUserConfiguration(DefaultTestConfigutation.class)
+        .withConfiguration(AutoConfigurations.of(IgniteAutoConfiguration.class, IgniteRepositoryAutoConfiguration.class));
+
+
+    /** Test default autoconfiguration */
+    @Test
+    public void testDefaultConfiguration() {
+        contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> {
+            assertThat(context).hasSingleBean(ObjectRepository.class);
+        });
+    }
+
+    /** Test configuration with @EnableIgniteRepositories */
+    @Test
+    public void testOverrideConfiguration() {
+        contextRunner.withUserConfiguration(OverrideConfiguration.class).run((context) -> {
+            assertThat(context).hasSingleBean(ObjectRepository.class);
+        });
+    }
+
+    /** Test configuration with @EnableIgniteRepositories and invalid base package */
+    @Test
+    public void testIvalidBasePackage() {

Review comment:
       Small typo, testI**n**validBasePackage

##########
File path: modules/spring-boot-autoconfigure-ext/pom.xml
##########
@@ -56,6 +56,20 @@
             <scope>provided</scope>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-spring-data_2.2-ext</artifactId>

Review comment:
       I wonder if we can make this work for all of the supported spring-data versions?
   Extensions have different packages, so we shouldn't have any trouble with this.
   But if that's too much work I guess the most recent version will do just fine

##########
File path: modules/spring-boot-thin-client-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/data/IgniteRepositoriesAutoConfigurationRegistar.java
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.springframework.boot.autoconfigure.data;
+
+import java.lang.annotation.Annotation;
+import org.apache.ignite.springdata22.repository.config.EnableIgniteRepositories;
+import org.apache.ignite.springdata22.repository.config.IgniteRepositoryConfigurationExtension;
+import org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport;
+import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
+import org.springframework.data.repository.config.RepositoryConfigurationExtension;
+
+/**
+ * {@link ImportBeanDefinitionRegistrar} used to auto-configure Ignite Spring Data Repositories.
+ */
+public class IgniteRepositoriesAutoConfigurationRegistar extends AbstractRepositoryConfigurationSourceSupport {

Review comment:
       Typo, Regist**r**ar

##########
File path: modules/spring-boot-autoconfigure-ext/src/main/java/org/apache/ignite/springframework/boot/autoconfigure/IgniteRepositoryAutoConfiguration.java
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.springframework.boot.autoconfigure;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.springdata22.repository.IgniteRepository;
+import org.apache.ignite.springdata22.repository.config.EnableIgniteRepositories;
+import org.apache.ignite.springdata22.repository.config.IgniteRepositoryConfigurationExtension;
+import org.apache.ignite.springdata22.repository.support.IgniteRepositoryFactoryBean;
+import org.apache.ignite.springframework.boot.autoconfigure.data.IgniteRepositoriesAutoConfigurationRegistar;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+
+
+/**
+ * {@link EnableAutoConfiguration Auto-configuration} for Ignite Spring Data's Repositories.
+ * <p>
+ * Activates when there is a bean of type {@link org.apache.ignite.Ignite} configured in the
+ * context, the Ignite Spring Data {@link IgniteRepository} type is on the classpath,
+ * and there is no other, existing {@link IgniteRepository} configured.
+ * <p>
+ * Once in effect, the auto-configuration is the equivalent of enabling Ignite repositories
+ * using the {@link EnableIgniteRepositories @EnableIgniteRepositories} annotation.
+ * <p>
+ * This configuration class will activate <em>after</em> the Ignite node auto-configuration.
+ */
+@Configuration
+@ConditionalOnBean(Ignite.class)
+@ConditionalOnClass(IgniteRepository.class)
+@ConditionalOnMissingBean({IgniteRepositoryFactoryBean.class, IgniteRepositoryConfigurationExtension.class})
+@Import(IgniteRepositoriesAutoConfigurationRegistar.class)

Review comment:
       Typo, Regist**r**ar




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org