java - Spring AOP aspect with annotations is not working for base class -


i have annotation defined below

@target({elementtype.type, elementtype.method}) @retention(retentionpolicy.runtime) @inherited public @interface otpflow { } 

and class defined below

public abstract class {   @otpflow   public modelandview dosomething() {     //do , return modelandview   } } 

class b controller defined below

@controller @requestmapping(value = {"/someurl"}) public class b extends {   @requestmapping(value = {"/get"}, method = {requestmethod.post, requestmethod.get})   public modelandview get(httpservletrequest request, httpservletresponse response) {     return dosomething();   } } 

aspect defined

@component @aspect public class otpaspect { private static final logger logger = loggerfactory.getlogger(otpaspect.class);  @pointcut("@annotation(otpflow)") public void otpflow() {}  @around("otpflow()") public object checkotp(proceedingjoinpoint joinpoint) {     try {         logger.info("inside aspect");         return joinpoint.proceed();     } catch (throwable e) {         throw new runtimeexception(e);     } } } 

the problem when access "/someurl/get" url, aspect not execute. when annotate "get" method of class b, aspect executes.

so basically, annotated methods of superclass not invoke aspect.

what issue? there other way achieve this? appreciated. thanks

i want offer alternative m. deinum , marios have said correctly: use aspectj instead of spring aop. aspectj not rely on proxies, faster, more powerful , integrates nicely spring described in spring manual, section 9.8, using aspectj spring applications. aspectj want works out of box.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -