| LogAdvice.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * The contents of this file are subject to the terms of the Liferay Enterprise
5 * Subscription License ("License"). You may not use this file except in
6 * compliance with the License. You can obtain a copy of the License by
7 * contacting Liferay, Inc. See the License for the specific language governing
8 * permissions and limitations under the License, including but not limited to
9 * distribution rights of the Software.
10 *
11 *
12 *
13 */
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 /**
26 * <a href="LogAdvice.java.html"><b><i>View Source</i></b></a>
27 *
28 * @author Karthik Sudarshan
29 * @author Brian Wing Shun Chan
30 * @author Michael Young
31 * @deprecated
32 */
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 }