Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Interceptors can be chained together to create an Interceptor "Stack". If an action needed neeeds to check the client's credentials, log the action, and time the action, all of these routines, and more, could be made part of the same Interceptor Stack.

Interceptors are implemented as Java classes, and so each Interceptor has a unique class name. To make it easier to reference Interceptors, each class can be registered with the framework and given a unique, simpler name.

Code Block
xml
xml
titleRegistering Interceptors
<interceptors>
  <interceptor name="security" class="com.mycompanycompany.security.SecurityInterceptor"/>
  <interceptor-stack name="secureStack">
    <interceptor-ref name="security"/>
    <interceptor-ref name="defaultStack"/>
  </interceptor-stack>
</interceptors>

(tick) Individual Interceptors and Interceptors Stacks can be "mixed and matched" in any order when defining an Interceptor Stack.

(tick) The framework will invoke each Interceptor on the stack in the order it is defined.

Most applications will define a default Interceptor Stack, such as

<default-interceptor-ref name="secureStack"/>

but each any action can may also define it's its own local stack.

Code Block
xml
xml
titleA local Interceptor Stack
<action name="VelocityCounter" class="comorg.opensymphonyapache.webworkstruts2.example.counter.SimpleCounter">
    <result name="success">...</result>
    <interceptor-ref name="defaultComponentStack"/>
</action>

...