-
Jul 27th, 2012, 07:27 PM
#1
AOP weaving is not working with Spring MVC 3.1.0 and AOP 1.6.9
Hi,
Help will be appreciated.
Here is my Use case and approach.
1. Need to validate the User before get in to the any method/s.
For this I created
1. A annotation class BusinessValidation
@Retention(RetentionPolicy.RUNTIME)
@Target(value=ElementType.METHOD)
public @interface BusinessValidation {
}
2. Created an Aspect class
@Component
@Aspect
public class BusinessAspect {
@Before("execution(* com.tutorials.spring.aop..*.*(..)) && " +
"args(id,email,..) && " +
"@annotation(BusinessValidation)")
public void validate(int id, string email){
// VALIDATION CODE
}
}
3. Controller Class
public class Controller {
@Autowired
private XXXFacade facade;
@BusinessValidation
@RequestMapping(value = "/xxx", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody ResponseEntity<xxx> getXXX(@RequestParam(value = "id", required = false) int id,
@RequestParam( value = "email") email, Model model) throws Exception
{
// CODE
}
}
4. Config xml -servlet.xml - I have following entries
<bean id="businessAspect" class="com.tutorials.spring.aop.BusinessAspect"/>
<aop:aspectj-autoproxy proxy-target-class="true" />
There is no problem in server start up. Aspect never invoked by calling the getXXX() method in my controller class.
I m using Java 6 update 24, Spring 3.1.0, AspectJ 1.6.9, Aspectweaver 1.6.9, spring-aop 3.1.0.
Can you tell me what is the problem?
Can i use AOP and custom annotation with Spring MVC?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules