Implementing after advice

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" ...

Get Java 9 Dependency Injection now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.