| PropsUtilTask.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.util;
16
17 import org.apache.tools.ant.BuildException;
18 import org.apache.tools.ant.Task;
19
20 /**
21 * <a href="PropsUtilTask.java.html"><b><i>View Source</i></b></a>
22 *
23 * @author Brian Wing Shun Chan
24 */
25 public class PropsUtilTask extends Task {
26
27 public void execute() throws BuildException {
28 ClassLoader antClassLoader = getClass().getClassLoader();
29
30 Thread currentThread = Thread.currentThread();
31
32 ClassLoader contextClassLoader = currentThread.getContextClassLoader();
33
34 try {
35 currentThread.setContextClassLoader(antClassLoader);
36
37 getProject().setUserProperty(_result, PropsUtil.get(_key));
38 }
39 finally {
40 currentThread.setContextClassLoader(contextClassLoader);
41 }
42 }
43
44 public void setKey(String key) {
45 _key = key;
46 }
47
48 public void setResult(String result) {
49 _result = result;
50 }
51
52 private String _key;
53 private String _result;
54
55 }