I'm really having problem in advicing methods with pointcuts expressions. I have the following configuration:
Spring 3.1.2.RELEASE
pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.2</version>
</dependency>
servlet.xml
<aop:aspectj-autoproxy/>
the class I want to advice
@Repository(value="userDaoImpl")
@Transactional
public class UserDaoImpl implements UserDao{
//attributes and methods
@Override
public void delete(ProfiledUser user) throws HibernateException
{
sessionFactory.getCurrentSession().delete(user);
}
}
it implements the UserDao
Interface which extends a GenericDao<T>
Interface
here's my Advice
@Aspect
@Component("userDeletionAspect")
public class UserDeletionAspect {
@Pointcut("execution(public void aa.bb.cc.dd.UserDaoImpl.delete(..))")
public void objectDeletionPointcut(){}
@Before("objectDeletionPointcut()")
public void notifyDeletion(JoinPoint jp)
{
System.out.println("pointcut executed");
}
}
which doesn't work. It means that when the UserDaoImpl's delete method is executed it isn't intercepted at all.
From Spring Documentation I read that spring proxies work with Interfaces so I tried to change the Pointcut definition as follow:
@Pointcut("execution(* aa.bb.cc.dd.GenericDao.delete(..))")
but nothing changes.
How can I intercept the .delete()
method of the UserDaoImpl
class?