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

2020-02-10 Thread GitBox
ingvard 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_r377089774
 
 

 ##
 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:
   Please remove the dead code.


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] ingvard commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
ingvard 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_r377087219
 
 

 ##
 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:
   code style, please add space.


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] ingvard commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
ingvard 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_r377089279
 
 

 ##
 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:
   code style, please add space.


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] ingvard commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
ingvard 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_r377089080
 
 

 ##
 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:
   code style, please add space.


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] ingvard commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
ingvard 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_r377088988
 
 

 ##
 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:
   code style, please add space.


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] ingvard commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
ingvard 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_r377089987
 
 

 ##
 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:
   Code style, space.


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] ingvard commented on a change in pull request #7381: It is needed to set used cache for Spring Data dynamically

2020-02-10 Thread GitBox
ingvard 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_r377090363
 
 

 ##
 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:
   space here and below.


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