on 02-16-2016 2:21 PM
How can create aspect for annotated methods (with my own annotation) in @Controller class? I've tried by spring-mvc-config.xml or adding aop.xml as is said here: https://wiki.hybris.com/display/release5/Spring+AOP+in+the+hybris+Commerce+Suite. Furthermore the second way works fine in core module or even in for example *Filter classes in storefront module.
I have the same problem, and for some reason I cannot use aspectj annotated classes directly. So instead of annotating the aspect with @Aspect and @Around annotations, I simply configured the aspect behavior in the -spring.xml file of my extension (not the storefront one):
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">;
<context:annotation-config/>
<context:component-scan base-package="com.mypackage" />
<aop:config proxy-target-class="true" expose-proxy="true">
<aop:aspect id="myAdviseAspect" ref="myAspect">
<aop:around method="advise"
pointcut="execution(* *(..)) && @annotation(annotation)"/>
</aop:aspect>
</aop:config>
<bean name="myAspect" class="com.mypackage.MyAspect"/>
</beans>
Then I simply declared the method "advise" like this:
public Object advise(final ProceedingJoinPoint joinPoint, MyAnnotation annotation) throws Throwable {
...
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.