I have some common code must be injected into service
method of any servlet .
Thus, i build a mother servlet SuperController
:
public class SuperController extends HttpServlet{
private HttpServletRequest lastRequest ;
//........
public void service(HttpServletRequest req,HttpServletResponse res){
setLastRequest(req); // example of common code
}
}
Then, all other servlets extends from this servlet .
public GalleryServlet extends SuperController{
public void service(HttpServletRequest req,HttpServletResponse res){
//instead of running here the common code , use AOP.
// Then , the other code
}
}
I want to execute the common code ( i.e: setLastRequest(req)
) using AOP , since super.service(req,res)
raised ERROR 405
.
com.ControllerAspect.java
@Before("* com.SuperController+.service(..)")
public void doStuffBeforeService(JoinPoint joinPoint) {
// do stuff here
}
How to Use Spring AOP :
Does this pointcut
* com.SuperController+.service(..)
includesservice
methods in all classes inherits fromcom.SuperController
.How to access to arguments (req & res ) of service method inside
doStuffBeforeService
?