Announcement Announcement Module
Collapse
No announcement yet.
How to use SpEL inside @CacheEvict annotation's key attribute Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use SpEL inside @CacheEvict annotation's key attribute

    Consider the following class with one static method

    Code:
     public class SomeClass {
        public static String getCacheKey() {
             //do something to return a cache key
        }
    }
    I want to invoke this method from a @CacheEvict annotation

    Code:
    @CacheEvict(value = "someNamespacedCacheName", beforeInvocation = false, key = "<CALL getCacheKey in SomeClass FROM HERE USING SpEL>")
    public void doSomething() {
    }
    How would I do that ? I tried the following two without any luck

    Code:
    @CacheEvict(value = "someNamespacedCacheName", beforeInvocation = false, key = "#{T(xx.xx.SomeClass).getCacheKey()"}
    and

    Code:
    @CacheEvict(value = "someNamespacedCacheName", beforeInvocation = false, key = "T(xx.xx.SomeClass).getCacheKey()"
    I never hit my logic inside doSomething .. or in other words, spring never calls my static method to retrieve the key. What am I missing? How would I call an arbitrary static method from a @CacheEvict annotation's key attribute ?
Working...
X