wood burning stoves 2.0*
The moose likes Other Application Frameworks and the fly likes Stripes: how to set interceptor only for a group of actions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Stripes: how to set interceptor only for a group of actions?" Watch "Stripes: how to set interceptor only for a group of actions?" New topic
Author

Stripes: how to set interceptor only for a group of actions?

Vadim Vararu
Ranch Hand

Joined: Jan 03, 2009
Posts: 147
I would like to write an interceptor that checked id user is logged, or not. But i need this to work only for a group of Actions (CMS). I don't need it to intercept for frontend. Is it possible?


If you think you've done too much, usually it means you've done too few.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

An interceptor will intercept all requests for a given set of LifecyclePhases. There is nothing that you can tag the interceptor with to specify which actions. However, you can, in your interceptor, determine which Actions are acted upon. So the interceptor will execute every time, but you decide which actions matter.


GenRocket - Experts at Building Test Data
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
I've used something like the following to constrain an interceptor to particular actions.


It's also possible to restrict intercepts to particular methods using the Before and After annotations, either positively:@Before(on="save") or negatively: @Before(on="!save").


Ping & DNS - my free Android networking tools app
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

In addition to what Ulf said, seeing as how you could have a huge amount of Actions to test against, you could use the servlet path:

String servletPath = executionContext.getActionBeanContext().getRequest().getServletPath();

This means all your "front-end" actions would reside in a specific path and your secure actions in a different path

http://yourserver.com/public/action
http://yourserver.com/protected/action
Vadim Vararu
Ranch Hand

Joined: Jan 03, 2009
Posts: 147
Thank you very much guys! I guess last variant will be more suitable for my case cause my actions paths differs in ..../frontend/... and .../backend/...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stripes: how to set interceptor only for a group of actions?
 
Similar Threads
Help need to exclude list of bean classes from interceptors
interceptors
EJB3 Injection - how to Inject it into struts 2 Action?
Interceptor messes up action class in Struts2
Preempting a workflow