sudeepdino008
sudeepdino008

Reputation: 3364

Pointcuts not intercepting appropriate points

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")
   }
}

The callSetup is not being intercepted by the Pointcut. Any idea what's wrong with my code?

It's a large configuration file...the relevant part is:

<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"/>

Upvotes: 0

Views: 37

Answers (1)

Vinit Prajapati
Vinit Prajapati

Reputation: 1613

Please check this

http://eggsylife.co.uk/2010/02/03/spring-annotation-based-aop-and-intercepting-the-ball/

and it should be execution instead of call

Upvotes: 1

Related Questions