1 package gboat2.base.logging.aspectj;
2
3 import org.aspectj.lang.ProceedingJoinPoint;
4 import org.slf4j.Logger;
5 import org.slf4j.LoggerFactory;
6
7
8
9
10
11
12
13
14
15
16 public final class LogServiceAspectJ implements ILogServiceAspectJ {
17
18 public LogServiceAspectJ() {
19 super();
20 }
21
22 private static final Logger logger = LoggerFactory.getLogger(LogServiceAspectJ.class.getName());
23
24 @Override
25 public Object invoke(ProceedingJoinPoint pjp) throws Throwable {
26
27 String serviceName = pjp.getTarget().getClass().getName();
28
29 String methodName = pjp.getSignature().getName();
30
31 long startTime = System.currentTimeMillis();
32
33 logger.debug(" Begin Call Service {},Visit method {} ", new String[] { serviceName, methodName });
34
35 Object ret = pjp.proceed();
36
37 long endTime = System.currentTimeMillis();
38
39 logger.debug(" End Call Service {},Visit method {} , cost {} ms ", new String[] { serviceName, methodName,
40 String.valueOf(endTime - startTime) });
41
42 return ret;
43 }
44
45 public int getOrder() {
46 return Integer.MAX_VALUE;
47 }
48
49 }