Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Spring Interceptor vs AOP

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When working on aop, what is the difference between Interceptor and AOP and When to use each?
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DO you mean MVC interceptor or AOP Interceptor?

MVC Interceptor is a MVC only concept. They are more or less like Servlet Filters. They can intercept requests to the controller only. AOP can be used to intercept calls to any public method in any Spring loaded bean.

So, the question is when you would use one over the other?
AOP is only option to use if you are trying to weave code into your service layer.
A Controller method can be intercepted by either an Aspect or a HandlerInterceptor. The differrence is that the AOP advice only has access to the controller being called, and the parameters being passed to the method. A HandlerInterceptor always has access to the complete HttpRequest, HttpResponse and the object being called. So, if your interceptor is doing something that requires it to always have access to the Request and response, you should use HandlerInterceptor. If you want to do something with the parameters to the controller method, you should write an Aspect

 
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic