저는 pointcuts 표현식을 사용하는 방법을 조언하는 데 정말로 문제가 있습니다.@Pointcut 표현식을 어떻게 작동시킬 수 있습니까?
봄 내가 원하는 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/>
클래스 : 나는 다음과 같은 구성을 가지고 조언에
@Repository(value="userDaoImpl")
@Transactional
public class UserDaoImpl implements UserDao{
//attributes and methods
@Override
public void delete(ProfiledUser user) throws HibernateException
{
sessionFactory.getCurrentSession().delete(user);
}
}
그것은
여기에 작동하지 않습니다 내 조언
@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");
}
}
의 GenericDao<T>
인터페이스를 확장 UserDao
인터페이스을 구현합니다. 이것은 UserDaoImpl의 delete 메소드가 실행될 때 전혀 인터셉트되지 않는다는 것을 의미합니다.
@Pointcut("execution(* aa.bb.cc.dd.GenericDao.delete(..))")
하지만 아무것도 변경 : 봄 문서에서
는 그 봄의 프록시 그래서 다음과 같이 포인트 컷 정의를 변경하려 인터페이스와 일을 참조하십시오. UserDaoImpl
클래스의 .delete()
방법을 가로채는 방법은 무엇입니까? 당신은 당신의 pointcut 표현에 구체적인 클래스 또는 특정 인터페이스의 구현 중 하나를 타겟팅 할 수 있습니다 -
중복 'objectDeletionPointcut'질문에서를 제거하십시오) –
@MarkusCoetzee는 아직도 그() 메소드를 삭제 가로 챌 수없는 제안으로도 코드를 변경, 불행하게도 :-) – MaVVamaldo