AspectJ @After

After (finally) advice runs however a matched method execution exits. It is declared using @After annotation.

For sample code in details, refer the following link. Click Here

1. Aspect Class

Now write a Aspect which will profile our business method.

package com.kruders.spring.aspect;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
public class BusinessAspect {
    @Pointcut("execution(* com.kruders.spring.aop.BusinessImpl*.*(..))")
    public void businessMethods() { }
    public void after() {
        System.out.println("After method is called");

2. Output

When you run the above example you’ll get an output like:

Do Something Here
After method is called

No comments yet.

Leave a Reply