Skip to content

Instantly share code, notes, and snippets.

@SlimeQ
Created October 8, 2015 23:50
Show Gist options
  • Save SlimeQ/828ade97f95101a35a82 to your computer and use it in GitHub Desktop.
Save SlimeQ/828ade97f95101a35a82 to your computer and use it in GitHub Desktop.
@Aspect
public class LoggingAspect {
// private static Logger log = Logger.getLogger(LoggingAspect.class);
// ripped from [http://www.mkyong.com/spring3/spring-aop-aspectj-annotation-example/]
@Around("@annotation(org.springframework.web.bind.annotation.ExceptionHandler)")
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println("logAround() is running!");
System.out.println("hijacked method : " + joinPoint.getSignature().getName());
System.out.println("hijacked arguments : " + Arrays.toString(joinPoint.getArgs()));
System.out.println("Around before is running!");
Object ret = joinPoint.proceed(); //continue on the intercepted method
System.out.println("Around after is running!");
System.out.println("******");
return ret;
}
// // ripped from [http://stackoverflow.com/a/10982948/4743597]
// @AfterThrowing(pointcut = "execution(* *.*(..))", throwing = "ex")
// public void errorInterceptor(Exception ex) {
// // if (log.isDebugEnabled()) {
// System.out.println("Error Message Interceptor started");
// // }
//
// // DO SOMETHING HERE WITH EX
// System.out.println( ex.getCause().getMessage());
//
//
// // if (log.isDebugEnabled()) {
// System.out.println("Error Message Interceptor finished.");
// // }
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment