Announcement Announcement Module
Collapse
No announcement yet.
AOP + Struts 2 help. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP + Struts 2 help.

    struts.xml
    ==========

    <package name="QueueAction-default" extends="corsair-default">

    <action name="listQueue" class="listQueueAction">
    <result name="success" type="tiles">list.queues.view</result>
    <interceptor-ref name="store">
    <param name="operationMode">RETRIEVE</param>
    </interceptor-ref>
    <interceptor-ref name="corsairStack"/>
    </action>

    <action name="addQueue" class="queueAction">
    <result name="input" type="tiles">queue.view</result>
    <interceptor-ref name="corsairStack"/>
    </action>

    <action name="updateQueue" class="queueAction" method="update">
    <result name="input" type="tiles">queue.view</result>
    <result type="redirect">listQueue.action</result>
    <interceptor-ref name="store">
    <param name="operationMode">STORE</param>
    </interceptor-ref>
    <interceptor-ref name="corsairPrepareParamsStack"/>
    </action>

    <action name="createQueue" class="queueAction" method="create">
    <result name="input" type="tiles">queue.view</result>
    <result type="redirect">listQueue.action</result>
    <interceptor-ref name="store">
    <param name="operationMode">STORE</param>
    </interceptor-ref>
    <interceptor-ref name="corsairPrepareParamsStack"/>
    </action>

    <action name="editQueue" class="queueAction">
    <result name="input" type="tiles">queue.view</result>
    <interceptor-ref name="corsairPrepareParamsStack"/>
    </action>


    </package>




    Ctx.xml
    =======

    <bean id="queueAction" class="com.certapay.corsair.admin.queue.QueueActio n" scope="prototype">
    <property name="facade">
    <ref bean="queueFacade"/>
    </property>
    <property name="allowableParmsList">
    <list>
    <value>id</value>
    <value>autoClose</value>
    <value>queueName</value>
    </list>
    </property>
    </bean>


    <bean name="loggingAutoProxy" class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
    <property name="beanNames">
    <value>queueAction</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>actionPerformanceLogger</value>
    </list>
    </property>
    </bean>


    Problem, when invoking the editQueue action from with the listqueue.jsp with the queueid, somehow they are null when got to the queueAction class itself. This flow works perfectly good without the interceptor.

    Am I missing something??

    Thanks indvancd for the help

  • #2
    Am I missing something??
    Well for your post you are missing the [ code][/code ] tags, please use those when posting code, makes it more readable!

    Next to that what is your actionPerformanceLogger doing? Can we see the implementation...

    Comment


    • #3
      actionPerformanceLogger

      Hi mdeinum,

      Thanks for the reply. Follwing is the implementation of the actionPerformanceLogger


      Code:
      <bean id="actionPerformanceLogger"  class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
            <property name="advice">
               <ref local="performanceLoggingInterceptor"/>
            </property>
            <property name="patterns">
               <value>.*.</value>
            </property>
         	</bean>
      
      
      
      
      
      package com.certapay.corsair.domain.logging;
      
      import java.lang.reflect.Method;
      import org.springframework.aop.AfterReturningAdvice;
      import org.springframework.aop.MethodBeforeAdvice;
      import org.springframework.aop.ThrowsAdvice;
      import org.apache.log4j.Logger;
      
      public class PerformanceLoggingInterceptor implements MethodBeforeAdvice, AfterReturningAdvice, ThrowsAdvice{
      //	private static Log log =  
      	protected Logger logger = Logger.getLogger(PerformanceLoggingInterceptor.class); 
      
      	
      	public PerformanceLoggingInterceptor(){
      	}
      	
      	public void before(Method arg0, Object[] arg1, Object arg2) throws Throwable {
      		 
      		logger.info("BEG: CLASS - " + arg2.toString() + " METHOD - " + arg0.getName());
      	}
      	
      	public void afterReturning(Object arg0, Method arg1, Object[] arg2, Object arg3) throws Throwable {		
      		 
      		logger.info("END:  CLASS - " + arg3.toString() + " METHOD - " + arg1.getName());		
      	}
      	
      	public void afterThrowing(Method m, Object[] args, Object target, Throwable ex) 
      	{ 	
      		 
      		logger.info("Exception in method: "+m.getName()+" Exception is: "+ex.getMessage());	
      	}
      
      }

      Comment


      • #4
        Any news regarding AOP + Struts 2?
        I am having the same problem here.
        If I turn-off auto-proxy the fields of the actions are automatically set, otherwise, if auto-proxy is on for AOP, they are all null (the setter methods are not called automatically).

        Thank you!

        Comment


        • #5
          Any luck?

          Just wondering if anyone got this working?

          Having same problem here, @Autowired and @Resource fields are not wired when using AOP on Struts 2 actions....

          Thanks!

          Comment

          Working...
          X