1
14
15 package com.liferay.portal.kernel.servlet;
16
17 import com.liferay.portal.kernel.util.ClassUtil;
18
19
24 public class WebDirDetector {
25
26 public static String getLibDir(ClassLoader classLoader) {
27 String libDir = ClassUtil.getParentPath(
28 classLoader, "com.liferay.util.bean.PortletBeanLocatorUtil");
29
30 if (libDir.endsWith("/WEB-INF/classes/")) {
31 libDir = libDir.substring(0, libDir.length() - 8) + "lib/";
32 }
33 else {
34 int pos = libDir.indexOf("/WEB-INF/lib/");
35
36 if (pos != -1) {
37 libDir = libDir.substring(0, pos) + "/WEB-INF/lib/";
38 }
39 }
40
41 return libDir;
42 }
43
44 public static String getRootDir(ClassLoader classLoader) {
45 return getRootDir(getLibDir(classLoader));
46 }
47
48 public static String getRootDir(String libDir) {
49 String rootDir = libDir;
50
51 if (rootDir.endsWith("/WEB-INF/lib/")) {
52 rootDir = rootDir.substring(0, rootDir.length() - 12);
53 }
54
55 return rootDir;
56 }
57
58 }