Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-issuemaster opened this issue Jan 13, 2015 · 10 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Jan 13, 2015

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:

  • #16245 ApplicationListener-like annotation for consuming application events

Referenced from: commits c7b324b

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented 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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 20, 2015

Stéphane Nicoll commented

Hello, can you please clarify?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented 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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented 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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented 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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 21, 2015

Stéphane Nicoll commented

That clarifies the scope, thanks!

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 26, 2015

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.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented 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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented 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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.