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

  • Webflow + Spring AOP

    Hi,
    I was wondering if it was possible to use Spring AOP to intercept methods invoked from a flow definition file like so

    flow-definition file :
    PHP Code:

    <action-state id="saveAndClose">

      <
    transition on="yes" to="endEdit">
        <
    evaluate expression="messageService.save(flowScope.message)" />
      </
    transition>
    </
    action-state
    I'm trying to intercept the call to the save method. While browsing the web I read that since Webflow uses reflexion to call methods it cannot be done directly so I decided to create the pointcut on the DAO that the bean MessageService uses to persist the object in the database like so :

    PHP Code:

    <aop:config>
        <
    aop:aspect ref="applicationConfigUtil">
         <
    aop:pointcut 
             expression
    ="execution (* mypackage.MessageDao.save(..))" 
              
    id="pcSaveMessage" />
           
               
               <
    aop:after method="reload" pointcut-ref="pcSaveMessage"/>

           </
    aop:aspect>
        </
    aop:config
    here is my aspect
    PHP Code:

    @Component
    public class ApplicationConfigUtil implements Serializable{

        public 
    void reload(){
            
    System.out.println("Reloading");

        }

    But the advice method never gets called. Is there a way to accomplish this (without using full AspectJ implementation) ?

    Any ideas?

    -----
    I'm using :
    Spring Webflow : 2.3.0
    Spring : 3.0.5
    Last edited by ufasoli; May 25th, 2011, 04:35 AM. Reason: Solved

  • #2
    I managed to get this one working finally. The first thing I had to do was to move my AOP stuff from the servlet-context.xml to applicationContext.xml. The second thing was to advice the parent interface (I had 2 interfaces GenericDAO and MessageDAO that extended the generic one) the method I was trying to advice was in the parent interface.
    Maybe this can help someone

    Comment

    Working...
    X