| ServiceVelocityAdvice.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 org.aspectj.lang.ProceedingJoinPoint;
18
19 /**
20 * <a href="ServiceVelocityAdvice.java.html"><b><i>View Source</i></b></a>
21 *
22 * @author Brian Wing Shun Chan
23 * @deprecated
24 */
25 public class ServiceVelocityAdvice {
26
27 public Object invoke(ProceedingJoinPoint proceedingJoinPoint)
28 throws Throwable {
29
30 Thread currentThread = Thread.currentThread();
31
32 ClassLoader contextClassLoader = currentThread.getContextClassLoader();
33
34 try {
35 if ((_classLoader != null) &&
36 (contextClassLoader != _classLoader)) {
37
38 currentThread.setContextClassLoader(_classLoader);
39 }
40
41 return proceedingJoinPoint.proceed();
42 }
43 catch (Throwable t) {
44 if (_exceptionSafe) {
45 return null;
46 }
47 else {
48 throw t;
49 }
50 }
51 finally {
52 if ((_classLoader != null) &&
53 (contextClassLoader != _classLoader)) {
54
55 currentThread.setContextClassLoader(contextClassLoader);
56 }
57 }
58 }
59
60 public void setClassLoader(ClassLoader classLoader) {
61 _classLoader = classLoader;
62 }
63
64 public void setExceptionSafe(boolean exceptionSafe) {
65 _exceptionSafe = exceptionSafe;
66 }
67
68 private ClassLoader _classLoader;
69 private boolean _exceptionSafe;
70
71 }