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

Reply via email to