1
14
15 package com.liferay.portal.spring.aop;
16
17 import com.liferay.portal.kernel.log.Log;
18 import com.liferay.portal.kernel.log.LogFactoryUtil;
19
20 import java.util.HashMap;
21 import java.util.Map;
22
23 import org.aspectj.lang.ProceedingJoinPoint;
24
25
33 public class LogAdvice {
34
35 public Object invoke(ProceedingJoinPoint proceedingJoinPoint)
36 throws Throwable {
37
38 String typeName = proceedingJoinPoint.getTarget().getClass().getName();
39
40 Log log = getLog(typeName);
41
42 if (log.isInfoEnabled()) {
43 log.info("Before " + typeName);
44 }
45
46 Object returnVal = proceedingJoinPoint.proceed();
47
48 if (log.isInfoEnabled()) {
49 log.info("After " + typeName);
50 }
51
52 return returnVal;
53 }
54
55 protected Log getLog(String typeName) {
56 Log log = _logs.get(typeName);
57
58 if (log == null) {
59 log = LogFactoryUtil.getLog(typeName);
60
61 _logs.put(typeName, log);
62 }
63
64 return log;
65 }
66
67 private static Map<String, Log> _logs = new HashMap<String, Log>();
68
69 }