You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide reusable parts of Cache implementation for others [SPR-12622] #17223
It seems that preliminary implementation of Annotation-based Event Listeners is sharing a great amount of code with Cache part of Spring. In our projects we had to duplicated necessary parts as Stéphane Nicoll has done.
My use cases:
My first use case was about @Audit. We wanted to track necessary actions in some controllers for audit trailing. It can access parameters, request, response etc... as in done Cache annotations.
My second use case was relatively simple to first one. We wanted to declaratively to track some product views, clicks etc... We created another annotation, @Track. It was also creating a context to access context parameters.
I would be glad to if necessary changes will be provided by means of #16245.
Could you please describe what you copy/pasted instead because I am not sure I am following. What the cache abstraction provides is a way to cache a method so that the SpEL expression is not computed every time (it's computed the first time it's actually used and reused later).
I don't see the link with your description, sorry.
Sorry Stephane, I was very busy past week and splitting necessary parts from our repository to provide a sample is not easy. Hope you provide this week.
Since Spring 4.1 Cache implementation of Spring has changed a lot. I am having difficulties to correspond some old classes with new one. Let me to explain clearly what I want with current 4.1 implementation.
Basically I want to create a EvaluationContext as Spring Cache has done. I am talking about specifically, org.springframework.cache.interceptor.CacheEvaluationContext in 4.1 which is package protected currently. I would be glad that if CacheEvaluationContext can be renamed to something more generic and move to another package to be reused by others. There are pretty much related classes such as "org.springframework.cache.interceptor.ExpressionEvaluator". For example, org.springframework.cache.interceptor.MethodCacheKey is part of cache package which is very suitable to store in a more common package.
MethodCacheKey has been moved and renamed to AnnotatedElementKey and a base CachedExpressionEvaluator class has been created. This should give the necessary flexibility to parse and cache expressions that are specified on an annotated element (i.e. method).
As for the context, it is very cache specific and sharing that publicly is not going to add much more to it I am afraid. I'd recommend to inspire yourself from that class and tailor it for your specific needs.
It has not landed in master yet but the plan is to merge that as part of 4.2 as well. I think it should be interesting for you as well. Let me know if the current contract requires an additional hook point. Thanks!
Activity
spring-projects-issues commentedon Jan 13, 2015
Stéphane Nicoll commented
Could you please describe what you copy/pasted instead because I am not sure I am following. What the cache abstraction provides is a way to cache a method so that the SpEL expression is not computed every time (it's computed the first time it's actually used and reused later).
I don't see the link with your description, sorry.
spring-projects-issues commentedon Jan 20, 2015
Stéphane Nicoll commented
Hello, can you please clarify?
spring-projects-issues commentedon Jan 20, 2015
cemo koc commented
Sorry Stephane, I was very busy past week and splitting necessary parts from our repository to provide a sample is not easy. Hope you provide this week.
spring-projects-issues commentedon Jan 20, 2015
Stéphane Nicoll commented
I don't necessary need a sample that I can run. I don't understand what pieces you're talking about so having more explanation about that would help.
spring-projects-issues commentedon Jan 21, 2015
cemo koc commented
Since Spring 4.1 Cache implementation of Spring has changed a lot. I am having difficulties to correspond some old classes with new one. Let me to explain clearly what I want with current 4.1 implementation.
Basically I want to create a EvaluationContext as Spring Cache has done. I am talking about specifically, org.springframework.cache.interceptor.CacheEvaluationContext in 4.1 which is package protected currently. I would be glad that if CacheEvaluationContext can be renamed to something more generic and move to another package to be reused by others. There are pretty much related classes such as "org.springframework.cache.interceptor.ExpressionEvaluator". For example, org.springframework.cache.interceptor.MethodCacheKey is part of cache package which is very suitable to store in a more common package.
spring-projects-issues commentedon Jan 21, 2015
Stéphane Nicoll commented
That clarifies the scope, thanks!
spring-projects-issues commentedon Jan 26, 2015
Stéphane Nicoll commented
MethodCacheKeyhas been moved and renamed toAnnotatedElementKeyand a baseCachedExpressionEvaluatorclass has been created. This should give the necessary flexibility to parse and cache expressions that are specified on an annotated element (i.e. method).As for the context, it is very cache specific and sharing that publicly is not going to add much more to it I am afraid. I'd recommend to inspire yourself from that class and tailor it for your specific needs.
spring-projects-issues commentedon Jan 26, 2015
Stéphane Nicoll commented
Maybe adding
#p(#a) support would be nice however. Is there anything else you had in mind for that class?spring-projects-issues commentedon Jan 26, 2015
cemo koc commented
I will give a try with latest trunk and inform you about details until weekend. I am hoping a sample demo project for others as well.
spring-projects-issues commentedon Jan 28, 2015
Stéphane Nicoll commented
Alright, I gave a bit more love in something related. Check MethodBasedEvaluationContext
It has not landed in master yet but the plan is to merge that as part of 4.2 as well. I think it should be interesting for you as well. Let me know if the current contract requires an additional hook point. Thanks!