Guest User

Untitled

a guest
Apr 23rd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. @Aspect
  2. @Configuration
  3. public class JpaInterceptor {
  4.  
  5. private static Logger logger = LoggerFactory.getLogger(JpaInterceptor.class);
  6.  
  7. private ThreadLocal<SimpleDateFormat> sdf = new ThreadLocal<SimpleDateFormat>() {
  8. @Override
  9. protected SimpleDateFormat initialValue() {
  10. return new SimpleDateFormat("[yyyy-mm-dd hh:mm:ss:SSS]");
  11. }
  12. };
  13.  
  14. @Pointcut("execution(public !void org.springframework.data.repository.Repository+.*(..))")
  15. public void jpaHandler() {
  16. }
  17.  
  18. @Around("jpaHandler()")
  19. public Object logMethodCall(ProceedingJoinPoint jp) throws Throwable {
  20. String methodName = jp.getSignature().getName();
  21. logger.info(sdf.get().format(new Date()) + methodName);
  22. return jp.proceed();
  23. }
  24.  
  25. }
Add Comment
Please, Sign In to add comment