Skip to content

Provide reusable parts of Cache implementation for others [SPR-12622] #17223

Closed

Description

@spring-projects-issues

cemo koc opened SPR-12622 and commented

This issue is a complementary issue to #16245.

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:

  1. 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.

  2. 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.


Affects: 4.1.4

Issue Links:

Referenced from: commits c7b324b

Activity

  1. spring-projects-issues commented on Jan 13, 2015

    @spring-projects-issues
    CollaboratorAuthor

    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.

  2. spring-projects-issues commented on Jan 20, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Stéphane Nicoll commented

    Hello, can you please clarify?

  3. spring-projects-issues commented on Jan 20, 2015

    @spring-projects-issues
    CollaboratorAuthor

    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.

  4. spring-projects-issues commented on Jan 20, 2015

    @spring-projects-issues
    CollaboratorAuthor

    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.

  5. spring-projects-issues commented on Jan 21, 2015

    @spring-projects-issues
    CollaboratorAuthor

    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.

  6. spring-projects-issues commented on Jan 21, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Stéphane Nicoll commented

    That clarifies the scope, thanks!

  7. spring-projects-issues commented on Jan 26, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Stéphane Nicoll commented

    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.

  8. spring-projects-issues commented on Jan 26, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Stéphane Nicoll commented

    Maybe adding #p (#a) support would be nice however. Is there anything else you had in mind for that class?

  9. spring-projects-issues commented on Jan 26, 2015

    @spring-projects-issues
    CollaboratorAuthor

    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.

  10. spring-projects-issues commented on Jan 28, 2015

    @spring-projects-issues
    CollaboratorAuthor

    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!

  11. added
    type: enhancement
    in: core
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions