[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377102581
 
 

 ##
 File path: 
modules/spring-data-2.2/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteRepositoryFactoryBean.java
 ##
 @@ -66,19 +66,19 @@ protected IgniteRepositoryFactoryBean(Class 
repositoryInterface) {
 try {
 Ignite ignite = (Ignite)ctx.getBean("igniteInstance");
 
-return new IgniteRepositoryFactory(ignite);
+return new IgniteRepositoryFactory(ignite,ctx);
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377101687
 
 

 ##
 File path: 
modules/spring-data-2.2/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -108,11 +134,38 @@ public IgniteRepositoryFactory(String springCfgPath) {
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
 
-repoToCache.put(repoItf, annotation.cacheName());
+String cacheName = evaluateExpression(annotation.cacheName());
+
+repoToCache.put(repoItf, cacheName);
 
 return super.getRepositoryMetadata(repoItf);
 }
 
+/**
+ *  evaluate the SpEL expression
+ *
+ * @param spelExpression SpEL expression
+ * @return the result of execution of the SpEL expression
+ */
+@NotNull private String evaluateExpression(String spelExpression) {
+return (String)resolver.evaluate(spelExpression,beanExpressionContext);
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377101419
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -108,11 +134,23 @@ public IgniteRepositoryFactory(String springCfgPath) {
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
 
-repoToCache.put(repoItf, annotation.cacheName());
+String cacheName = evaluateExpression(annotation.cacheName());
+
+repoToCache.put(repoItf, cacheName);
 
 return super.getRepositoryMetadata(repoItf);
 }
 
+/**
+ *  evaluate the SpEL expression
+ *
+ * @param spelExpression SpEL expression
+ * @return the result of execution of the SpEL expression
+ */
+@NotNull private String evaluateExpression(String spelExpression) {
+return (String)resolver.evaluate(spelExpression,beanExpressionContext);
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377101613
 
 

 ##
 File path: 
modules/spring-data-2.2/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -108,11 +134,38 @@ public IgniteRepositoryFactory(String springCfgPath) {
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
 
-repoToCache.put(repoItf, annotation.cacheName());
+String cacheName = evaluateExpression(annotation.cacheName());
+
+repoToCache.put(repoItf, cacheName);
 
 return super.getRepositoryMetadata(repoItf);
 }
 
+/**
+ *  evaluate the SpEL expression
+ *
+ * @param spelExpression SpEL expression
+ * @return the result of execution of the SpEL expression
+ */
+@NotNull private String evaluateExpression(String spelExpression) {
+return (String)resolver.evaluate(spelExpression,beanExpressionContext);
+}
+
+/**
+ * The method tryes to identify that the expression looks like SpEL 
extression
+ *
+ * @param expression string with a expression
+ * @return true if the string contains attributes of SpEL expression
+ * @see https://docs.spring.io/spring/docs/5.0.16.RELEASE/spring-framework-reference/core.html#expressions;>SpEL
+ */
+private boolean isSpelExpression(String expression) {
 
 Review comment:
   yes. thank you! fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377100655
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -73,8 +96,11 @@ public IgniteRepositoryFactory(IgniteConfiguration cfg) {
  *
  * @param springCfgPath A path to Ignite configuration.
  */
-public IgniteRepositoryFactory(String springCfgPath) {
+public IgniteRepositoryFactory(String springCfgPath, ApplicationContext 
ctx) {
 this.ignite = Ignition.start(springCfgPath);
+this.ctx = ctx;
+this.beanFactory = new 
DefaultListableBeanFactory(ctx.getAutowireCapableBeanFactory());
+this.beanExpressionContext = new 
BeanExpressionContext(beanFactory,null);
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377100016
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -53,8 +70,11 @@
  *
  * @param ignite
  */
-public IgniteRepositoryFactory(Ignite ignite) {
+public IgniteRepositoryFactory(Ignite ignite, ApplicationContext ctx) {
 this.ignite = ignite;
+this.ctx = ctx;
+this.beanFactory = new 
DefaultListableBeanFactory(ctx.getAutowireCapableBeanFactory());
+this.beanExpressionContext = new 
BeanExpressionContext(beanFactory,null);
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377100109
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -63,8 +83,11 @@ public IgniteRepositoryFactory(Ignite ignite) {
  *
  * @param cfg Ignite configuration.
  */
-public IgniteRepositoryFactory(IgniteConfiguration cfg) {
+public IgniteRepositoryFactory(IgniteConfiguration cfg, ApplicationContext 
ctx) {
 this.ignite = Ignition.start(cfg);
+this.ctx = ctx;
+this.beanFactory = new 
DefaultListableBeanFactory(ctx.getAutowireCapableBeanFactory());
+this.beanExpressionContext = new 
BeanExpressionContext(beanFactory,null);
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377062632
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,12 +126,25 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
-
-repoToCache.put(repoItf, annotation.cacheName());
+String cacheName = executeExpression(annotation.cacheName());
+repoToCache.put(repoItf, cacheName);
 
 return super.getRepositoryMetadata(repoItf);
 }
 
+/**
+ *  execute a SpEL extression
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377062080
 
 

 ##
 File path: 
modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java
 ##
 @@ -34,6 +34,16 @@
 @EnableIgniteRepositories
 public class ApplicationConfiguration {
 
+/**
+ * The bean with cache names
+ */
+@Bean
+public CacheNamesBean cacheNames() {
+CacheNamesBean bean = new CacheNamesBean();
+bean.setPersonCacheName("PersonCache");
+return bean;
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377062241
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,12 +126,25 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
-
-repoToCache.put(repoItf, annotation.cacheName());
+String cacheName = executeExpression(annotation.cacheName());
+repoToCache.put(repoItf, cacheName);
 
 return super.getRepositoryMetadata(repoItf);
 }
 
+/**
+ *  execute a SpEL extression
+ *
+ * @param spelExpression SpEL expression
+ * @return the result of execution of the SpEL expression
+ */
+@NotNull private String executeExpression(String  spelExpression) {
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377062162
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,12 +126,25 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
-
-repoToCache.put(repoItf, annotation.cacheName());
+String cacheName = executeExpression(annotation.cacheName());
+repoToCache.put(repoItf, cacheName);
 
 return super.getRepositoryMetadata(repoItf);
 }
 
+/**
+ *  execute a SpEL extression
+ *
+ * @param spelExpression SpEL expression
+ * @return the result of execution of the SpEL expression
+ */
+@NotNull private String executeExpression(String  spelExpression) {
+StandardBeanExpressionResolver resolver = new 
StandardBeanExpressionResolver();
+StandardEvaluationContext ec = new StandardEvaluationContext();
+ec.setBeanResolver(new 
BeanFactoryResolver(ctx.getAutowireCapableBeanFactory()));
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377061733
 
 

 ##
 File path: 
modules/spring-data-2.2/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java
 ##
 @@ -34,6 +34,16 @@
 @EnableIgniteRepositories
 public class ApplicationConfiguration {
 
+/**
+ * The bean with cache names
+ */
+@Bean
+public CacheNamesBean cacheNames() {
+CacheNamesBean bean = new CacheNamesBean();
+bean.setPersonCacheName("PersonCache");
+return bean;
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377056670
 
 

 ##
 File path: 
modules/spring-data-2.2/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,12 +126,41 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
+String cacheName = executeExpression(annotation.cacheName());
 
-repoToCache.put(repoItf, annotation.cacheName());
+repoToCache.put(repoItf, cacheName);
 
 return super.getRepositoryMetadata(repoItf);
 }
 
+/**
+ *  execute a SpEL extression
+ *
+ * @param spelExpression SpEL expression
+ * @return the result of execution of the SpEL expression
+ */
+@NotNull private String executeExpression(String  spelExpression) {
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r377052511
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,12 +126,25 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
-
-repoToCache.put(repoItf, annotation.cacheName());
+String cacheName = executeExpression(annotation.cacheName());
+repoToCache.put(repoItf, cacheName);
 
 return super.getRepositoryMetadata(repoItf);
 }
 
+/**
+ *  execute a SpEL extression
+ *
+ * @param spelExpression SpEL expression
+ * @return the result of execution of the SpEL expression
+ */
+@NotNull private String executeExpression(String  spelExpression) {
+StandardBeanExpressionResolver resolver = new 
StandardBeanExpressionResolver();
+StandardEvaluationContext ec = new StandardEvaluationContext();
+ec.setBeanResolver(new 
BeanFactoryResolver(ctx.getAutowireCapableBeanFactory()));
 
 Review comment:
   yes :-O .  Will be refactored


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-08 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376699505
 
 

 ##
 File path: 
modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/misc/ApplicationConfiguration.java
 ##
 @@ -34,6 +34,13 @@
 @EnableIgniteRepositories
 public class ApplicationConfiguration {
 
+@Bean
+public CacheNamesBean cacheNames() {
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-08 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376699512
 
 

 ##
 File path: 
modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/misc/CacheNamesBean.java
 ##
 @@ -0,0 +1,31 @@
+/*
+ * 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.springdata.misc;
+
+public class CacheNamesBean {
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-08 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376696363
 
 

 ##
 File path: 
modules/spring-data-2.0/src/test/java/org/apache/ignite/springdata/IgniteSpringDataCrudSelfExpressionTest.java
 ##
 @@ -0,0 +1,111 @@
+/*
+ * 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.springdata;
+
+import org.apache.ignite.springdata.misc.ApplicationConfiguration;
+import org.apache.ignite.springdata.misc.Person;
+import org.apache.ignite.springdata.misc.PersonExpressionRepository;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import 
org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Test with using repository which is configured by Spring EL
+ */
+public class IgniteSpringDataCrudSelfExpressionTest extends 
GridCommonAbstractTest {
+/** Repository. */
+private static PersonExpressionRepository repo;
+
+/** Context. */
+private static AnnotationConfigApplicationContext ctx;
+
+/** Number of entries to store */
+private static int CACHE_SIZE = 1000;
+
+/** {@inheritDoc} */
+@Override protected void beforeTestsStarted() throws Exception {
+super.beforeTestsStarted();
+
+ctx = new AnnotationConfigApplicationContext();
+
+ctx.register(ApplicationConfiguration.class);
+
+ctx.refresh();
+
+repo = ctx.getBean(PersonExpressionRepository.class);
+}
+
+/** {@inheritDoc} */
+@Override protected void beforeTest() throws Exception {
+super.beforeTest();
+
+fillInRepository();
+
+assertEquals(CACHE_SIZE, repo.count());
+}
+
+/** {@inheritDoc} */
+@Override protected void afterTest() throws Exception {
+repo.deleteAll();
+
+assertEquals(0, repo.count());
+
+super.afterTest();
+}
+
+/**
+ *
+ */
+private void fillInRepository() {
+for (int i = 0; i < CACHE_SIZE - 5; i++) {
+repo.save(i, new Person("person" + Integer.toHexString(i),
+"lastName" + Integer.toHexString((i + 16) % 256)));
+}
+
+repo.save((int) repo.count(), new Person("uniquePerson", 
"uniqueLastName"));
+repo.save((int) repo.count(), new Person("nonUniquePerson", 
"nonUniqueLastName"));
+repo.save((int) repo.count(), new Person("nonUniquePerson", 
"nonUniqueLastName"));
+repo.save((int) repo.count(), new Person("nonUniquePerson", 
"nonUniqueLastName"));
+repo.save((int) repo.count(), new Person("nonUniquePerson", 
"nonUniqueLastName"));
+}
+
+/** {@inheritDoc} */
+@Override protected void afterTestsStopped() throws Exception {
+ctx.destroy();
+}
+@Test
+public void testPutGet() {
+Person person = new Person("some_name", "some_surname");
+
+int id = CACHE_SIZE + 1;
+
+assertEquals(person, repo.save(id, person));
+
+assertTrue(repo.existsById(id));
+
+assertEquals(person, repo.findById(id).get());
+
+try {
+repo.save(person);
+
+fail("Managed to save a Person without ID");
+}
+catch (UnsupportedOperationException e) {
+//excepted
 
 Review comment:
   Tests in Spring Data don't use the class.  Are you sure that we need to 
change it ?


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-08 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376696279
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,11 +118,38 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
+String cacheName = null;
+if (!looksLikeExpression(annotation.cacheName())) {
+cacheName = annotation.cacheName();
+}
+else {
+SpelExpressionParser parser = new SpelExpressionParser();
+Expression expression = 
parser.parseExpression(annotation.cacheName());
+StandardEvaluationContext ec = new StandardEvaluationContext();
+ec.setBeanResolver(new 
BeanFactoryResolver(ctx.getAutowireCapableBeanFactory()));
+cacheName = (String)expression.getValue(ec);
+}
+repoToCache.put(repoItf, cacheName);
 
 repoToCache.put(repoItf, annotation.cacheName());
 
 return super.getRepositoryMetadata(repoItf);
 }
+/**
+ * The method tryes to identify SpEL extression
+ * @see https://docs.spring.io/spring/docs/5.0.16.RELEASE/spring-framework-reference/core.html#expressions;>SpEL
+ * @param expression
+ * @return
+ */
+
+private boolean looksLikeExpression(String expression) {
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-08 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376695732
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,11 +118,38 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
+String cacheName = null;
+if (!looksLikeExpression(annotation.cacheName())) {
+cacheName = annotation.cacheName();
+}
+else {
+SpelExpressionParser parser = new SpelExpressionParser();
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376694557
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,11 +118,38 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
+String cacheName = null;
+if (!looksLikeExpression(annotation.cacheName())) {
+cacheName = annotation.cacheName();
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376694547
 
 

 ##
 File path: 
modules/spring-data-2.2/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,10 +117,36 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
+//
https://stackoverflow.com/questions/11616316/programmatically-evaluate-a-bean-expression-with-spring-expression-language
+String cacheName = null;
+if (!looksLikeExpression(annotation.cacheName())) {
+cacheName = annotation.cacheName();
 
 Review comment:
   fixed.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376694534
 
 

 ##
 File path: 
modules/spring-data-2.2/src/main/java/org/apache/ignite/springdata22/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -44,6 +49,8 @@
 public class IgniteRepositoryFactory extends RepositoryFactorySupport {
 /** Ignite instance */
 private Ignite ignite;
+/** Spring application context */
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376693446
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,11 +118,38 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
+String cacheName = null;
+if (!looksLikeExpression(annotation.cacheName())) {
+cacheName = annotation.cacheName();
+}
+else {
+SpelExpressionParser parser = new SpelExpressionParser();
+Expression expression = 
parser.parseExpression(annotation.cacheName());
+StandardEvaluationContext ec = new StandardEvaluationContext();
+ec.setBeanResolver(new 
BeanFactoryResolver(ctx.getAutowireCapableBeanFactory()));
+cacheName = (String)expression.getValue(ec);
+}
+repoToCache.put(repoItf, cacheName);
 
 repoToCache.put(repoItf, annotation.cacheName());
 
 return super.getRepositoryMetadata(repoItf);
 }
+/**
+ * The method tryes to identify SpEL extression
+ * @see https://docs.spring.io/spring/docs/5.0.16.RELEASE/spring-framework-reference/core.html#expressions;>SpEL
+ * @param expression
+ * @return
+ */
+
+private boolean looksLikeExpression(String expression) {
 
 Review comment:
   The method checks the expression for attributes of SpEL. You are right. 
Fixed.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [ignite] schernolyas commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-07 Thread GitBox
schernolyas commented on a change in pull request #7381: It is needed to set 
used cache for Spring Data dynamically
URL: https://github.com/apache/ignite/pull/7381#discussion_r376693355
 
 

 ##
 File path: 
modules/spring-data-2.0/src/main/java/org/apache/ignite/springdata20/repository/support/IgniteRepositoryFactory.java
 ##
 @@ -107,11 +118,38 @@ public IgniteRepositoryFactory(String springCfgPath) {
 
 Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite 
cache using @RepositoryConfig " +
 "annotation to map this repository to the underlying cache.");
+String cacheName = null;
+if (!looksLikeExpression(annotation.cacheName())) {
+cacheName = annotation.cacheName();
+}
+else {
+SpelExpressionParser parser = new SpelExpressionParser();
+Expression expression = 
parser.parseExpression(annotation.cacheName());
+StandardEvaluationContext ec = new StandardEvaluationContext();
+ec.setBeanResolver(new 
BeanFactoryResolver(ctx.getAutowireCapableBeanFactory()));
+cacheName = (String)expression.getValue(ec);
+}
+repoToCache.put(repoItf, cacheName);
 
 repoToCache.put(repoItf, annotation.cacheName());
 
 return super.getRepositoryMetadata(repoItf);
 }
+/**
+ * The method tryes to identify SpEL extression
+ * @see https://docs.spring.io/spring/docs/5.0.16.RELEASE/spring-framework-reference/core.html#expressions;>SpEL
+ * @param expression
+ * @return
+ */
+
 
 Review comment:
   fixed


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:
us...@infra.apache.org


With regards,
Apache Git Services