Announcement Announcement Module
Collapse
No announcement yet.
After advice never called. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • After advice never called.

    Hi,

    I have the following advice:

    Code:
    @Aspect
    public class PictureUpdateAspect {
    	
    	@After("execution(public void dao.PictureDao.*(model.Picture)) and this(picture)")
    	public void onPictureAddDelete(Picture picture) {
    		System.out.println("test");
    	}
    }
    and that should be executed after the following methods:

    Code:
    package dao;
    
    public class PictureDao {
          public void save(Picture picture) {}
          public void delete(Picture picture) {}
    }
    in my XML config I have the following:

    Code:
    <bean id="pictureUpdateAspect" class="aspects.PictureUpdateAspect" />
    <aop:aspectj-autoproxy />
    But for some reason my aspect's method is never called.
    Is there anything I forgot?
    Last edited by incubator; Sep 27th, 2007, 07:09 AM.

  • #2
    Change 'this(picture)' to 'args(picture)'.

    When binding 'this' context, it refers to the proxy itself (in this case the proxied DAO object). You want to bind the Picture-typed argument there instead.

    Comment


    • #3
      I tried that too but it didnt work.
      I figured out why though.
      The PictureDao class extends from BaseDao<T, PK extends Serialisable>.

      and I read somewhere in here that Spring 2.0.6 with AspectJ seems to have difficulties with generics.
      When I tried this on a method on a different class (all non-generics) it worked fine.

      Comment

      Working...
      X