切入点不截取适当的点

时间:2014-06-18 13:09:15

标签: java spring aop aspectj spring-aop

EventServiceAspect.java

public EventServiceAspect{
    @Pointcut(value="call(* com.xyz.ServiceInput.callSetup(..))")
    public void anyCallSetup(){}

    @After("anyCallSetup() && @annotation(publishEventToService)")
    public void publishEvent(JoinPoint jp, PublishEventToService publishEventToService){
       log.warn("batman is here!");
    }
}

SampleClass.java

public SampleClass{
   @PublishEventToService
   public void someFunc(){
       serviceInput.callSetup("testing testing")
   }
}

Pointcut没有拦截callSetup。知道我的代码有什么问题吗?

这是一个大型配置文件......相关部分是:

<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:task="http://www.springframework.org/schema/task"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"
     default-init-method="init"> 

<aop:aspectj-autoproxy proxy-target-class = "true"/>

1 个答案:

答案 0 :(得分:1)