01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: EngineClassLoaderRifeWebappPath.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.engine;
09:
10: import com.uwyn.rife.tools.StringUtils;
11: import java.io.File;
12: import java.io.IOException;
13: import java.util.ArrayList;
14:
15: /**
16: * Helper class to avoid Double Check Locking
17: * and still have a thread-safe singleton pattern
18: */
19: public class EngineClassLoaderRifeWebappPath {
20: public static final ArrayList<String> RIFE_WEBAPP_PATH;
21:
22: static {
23: String rife_webapp_path = System
24: .getProperty("rife.webapp.path");
25: if (null == rife_webapp_path) {
26: RIFE_WEBAPP_PATH = null;
27: } else {
28: String seperator = File.pathSeparator;
29: if (-1 == rife_webapp_path.indexOf(File.pathSeparator)) {
30: seperator = ":";
31: }
32: ArrayList<String> path_elements = StringUtils.split(
33: rife_webapp_path, seperator);
34: RIFE_WEBAPP_PATH = new ArrayList<String>();
35:
36: File path = null;
37: for (String path_element : path_elements) {
38: path = new File(path_element);
39: if (path.exists()) {
40: try {
41: RIFE_WEBAPP_PATH.add(path.getCanonicalPath());
42: } catch (IOException e) {
43: // just skip this path id the canonical path can't be
44: // constructed
45: }
46: }
47: }
48: }
49: }
50: }
|