Created
October 8, 2015 23:50
-
-
Save SlimeQ/828ade97f95101a35a82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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