user509755
user509755

Reputation: 2981

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 some processing on that data.

Thanks

Upvotes: 1

Views: 2306

Answers (1)

skaffman
skaffman

Reputation: 403481

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.

Upvotes: 3

Related Questions