• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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").
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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/...
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic