0

Here is my code:

Controller class

@controller 
public class TrendController extends MyController{

@RequestMapping(method= RequestMethod.POST, value = "/trend")
public ModelAndView myReq(@RequestBody body, HttpHeaders hdr){
return super.myReq(body,hdr)
   }
}

MyController class

 public abstract class MyController implements ApplicationContextAware{

    protected ModelAndView myReq(@RequestBody body, HttpHeaders hdr){
    MyReqType req = null;

    req = unmrsl(body,hdr);

    }

protected MyReqType unmrsl(@RequestBody body, HttpHeaders hdr){
MyReqType  request = null;
.
.
.
return request;
}

}

AOP Configuration:

I've added my pointcut expression in myReq.xml

<bean id="myAspect" class = com.abc.xyz.aop.myInterceptor/>

<aop:config>
<aop:aspect ref="myAspect">
<aop pointcut id="myPrReq"
expression="execution(* com.abc.xyz.controllers.MyController.unmrsl(..)"/>
<aop:after pointcut-ref="myPrReq" method="myTestMthd"/>

Now.. I've written myTestMthd in com.abc.xyz.aop.myInterceptor.Java , and it suppose to hit my logic in myTestMthd after execution of unmrsl method in MyController. But it is not working as expected.

com.abc.xyz.aop.myInterceptor.Java

public class myInterceptor{

public void myTestMthd(JoinPoint call){
.
.
mylogic
.
.
  }
}
Pragya
  • 1
  • When you say "it is not working as expected" what does that mean? – user3486184 Aug 23 '17 at 20:08
  • It suppose to hit my logic in myInterceptor after executing unmrsl method right? But it is not. – Pragya Aug 23 '17 at 20:12
  • It has nothing to do with the fact that it is `protected` it has all to do with how Spring AOP works. Spring uses proxies and as such only method calls into the object pass through the proxy, internal method calls don't and as such don't get aspects applied. – M. Deinum Aug 24 '17 at 05:38

0 Answers0