April 2018
Intermediate to advanced
246 pages
6h 11m
English
Just like before advice, we can also implement other advice types. Let's take an example of after advice and around advice. For after advice, just add one method in the LoggingAspect class as follows:
//After advice method. public void printEndLog(JoinPoint joinPoint) { System.out.println(" ****** End of Method '"+joinPoint.getSignature().getName()); }
In after advice, we are just printing the method name. We also need to update the aspect configuration in the application context file. Just add an after advice entry for our logging aspect, as follows:
<aop:aspect id="myLoggin" ref="loggingAspect"> <aop:before pointcut-ref="employeeServiceMethods" method="printStartLog"/> <aop:after pointcut-ref="employeeServiceMethods" ...