ExecAndWait - Extending ExecuteAndWaitInterceptor

677 views Asked by At

Has any of you succeeded to extend the ExecuteAndWaitInterceptor and make your webapp use it ? I followed this example, but my interceptor is never accessed. Do these classes need to be named in a specific way?

I believe I need to extend it because when I try to run SecurityContextHolder.getContext() in my action, the authentication is null. My idea was to run this in the beforeInvocation() method.

Any ideas?

Thank you all!

UPDATE : Roman C.'s comment made it work! I added my interceptor to the <interceptors> area. This is the working struts.xml file :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <package name="test" extends="struts-default,json-default" namespace="/test">

        <interceptors>

            <interceptor name="myExecAndWaitInterceptor" class="xx.xxx.xxxx.action.FailureAvailabilityRateExecuteAndWaitInterceptor">
                <param name="delay">1000</param>
                <param name="delaySleepInterval">500</param>
            </interceptor>

            <interceptor-stack name="newStack">
                <interceptor-ref name="defaultStack" />
                <interceptor-ref name="myExecAndWaitInterceptor"/>
            </interceptor-stack>

        </interceptors>


        <action name="failureAvailabilityRate" class="xx.xxx.xxxx.action.FailureAvailabilityRateAction">
            <interceptor-ref name="newStack"/>
            <result name="wait">/jsp/test/wait.jsp</result>
            <result name="input">/jsp/test/failureAvailabilityRate.jsp</result>
            <result name="success">/jsp/test/failureAvailabilityRate.jsp</result>
        </action>

    </package>
</struts>
0

There are 0 answers