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/01 17:54:31 UTC

[GitHub] [ignite-extensions] dorozhKing opened a new pull request #41: IGNITE-13029 Ignite Spring Data autoconfiguration

dorozhKing opened a new pull request #41:
URL: https://github.com/apache/ignite-extensions/pull/41


   Ignite Spring Data autoconfiguration for spring-boot-autoconfigure-ext and spring-boot-thin-client-autoconfigure-ext modules.
   
   My points about using only spring-data-2.2-ext:
   1.  Ignite-spring-boot-autoconfigure-ext module have spring-boot 2.2 as dependency, which have spring data 2.2.3.RELEASE and spring-core 5.2. 
   Now autoconfigure module does not use any spring boot 2.2 feature, but can be garanted in future that with ignite autostarter can be used spring boot older version? 
   If not, use ignite-spring-data_2.0-ext or ignite-spring-data-ext does not have sense for me.
   2. Add ignite-spring-data_2.0-ext and ignite-spring-data-ext to autoconfigure will produce some redundant duplicate code (configuration and tests).
   3. In my opinion, its not the main problem. I dont know about motivation and may be I'm wrong, but, as for me, the main problem is we have 3 separeted artifact with one version instead of one artifact with few releases for different spring-data version.


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
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



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

Posted by GitBox <gi...@apache.org>.
dorozhKing commented on a change in pull request #41:
URL: https://github.com/apache/ignite-extensions/pull/41#discussion_r580390764



##########
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 wrote some thoughts about it in my comment in PR https://github.com/apache/ignite-extensions/pull/41#issue-565370788 
   In additional, spring-context 5.2.3 (used in ignite-spring-data_2.2-ext) incompatible with spring-context 5.0.16 (used in ignite-spring-data_2.0-ext) and I should make exclusion it from ignite-spring-data_2.0-ext. But if I do it and write some tests like IgniteAutoconfigureTest this test will be failed with NoSuchMethodError due to incompatibility spring-context.
   May be additional maven profile can help but should I do this? It may be too complex.




----------------------------------------------------------------
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



[GitHub] [ignite-extensions] asfgit closed pull request #41: IGNITE-13029 Ignite Spring Data autoconfiguration

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #41:
URL: https://github.com/apache/ignite-extensions/pull/41


   


-- 
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



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

Posted by GitBox <gi...@apache.org>.
SammyVimes commented on a change in pull request #41:
URL: https://github.com/apache/ignite-extensions/pull/41#discussion_r580398046



##########
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:
       True, let's just stick to the latest version then




----------------------------------------------------------------
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