Session aware spring bean
Is there any way to define a spring bean which will be notified when data in session has changed?
I would also like to know pure java solution if possible. All I want is when i add/edit/delete data in httpsession then I want one java class to be notified to do som开发者_开发技巧e processing on that data.
Thanks
You don't need Spring for this, the Servlet API provides that out-of-the-box, via the HttpSessionAttributeListener
interface:
This listener interface can be implemented in order to get notifications of changes to the attribute lists of sessions within this web application.
You declare it as a <listener>
in your web.xml
file. See here for an example.
In don't know of a specific Spring-friendly way of doing this, though, I think you'll have to use the above listener approach, and notify your Spring beans from there.
精彩评论