This week's book giveaway is in the Programmer Certification forum. We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
On my continuing quest into Stripes, I've started to get into interceptors. The SecurityInterceptor mentioned in the documentation actually answers neatly the question I had of how to avoid checking for an existing session everywhere in my action beans.
While a few areas they can be applied to are obvious -e.g. for everything a regular web app would use servlet filters for- I'm wondering what other things they make possible, since one can get at the ActionBean and ActionBeanContext objects through them. Does anyone have some use cases they thought particularly fitting for interceptors?
Interceptors provide a nice plug-in like architecture for Stripes. As you know there are already a few built in interceptors that ship with stripes. A while back I blogged about writing Stripes interceptors and my example using @NoCache made it into Stripes 1.5 as @HttpCache. It's pretty typical that an interceptor uses annotation to drive its configuration.
There is another interceptor out there (need to find a link) that allows you to specify @Session on action bean properties and the interceptor automatically retrieves and injects properties into the session for you. So there is another possible use case.
Unfortunately I've had my head buried in PHP the last few days so I am not thinking straight. As I think of some use cases I'll post them here.
On a project I was working on a few months ago I used an Interceptor to ensure requests were made via SSL (https). I also wrote a white list interceptor that runs a regex on request params and cleans them (poor mans XSS prevention).