Results 1 to 3 of 3

Thread: After advice never called.

  1. #1
    Join Date
    Aug 2005
    Posts
    28

    Default 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 at 07:09 AM.

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    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.

  3. #3
    Join Date
    Aug 2005
    Posts
    28

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •