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 2020/02/10 14:21:30 UTC

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

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 <a href="https://docs.spring.io/spring/docs/5.0.16.RELEASE/spring-framework-reference/core.html#expressions">SpEL</a>
+     */
+    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:
users@infra.apache.org


With regards,
Apache Git Services