001
014
015 package com.liferay.portal.module.framework;
016
017 import com.liferay.portal.kernel.util.StringPool;
018 import com.liferay.portal.kernel.util.StringUtil;
019 import com.liferay.portal.util.PropsValues;
020
021 import java.io.File;
022
023 import java.net.URL;
024
025
028 public class RuntimeClasspathResolver implements ClasspathResolver {
029
030 @Override
031 public URL[] getClasspathURLs() throws Exception {
032 File coreDir = new File(PropsValues.MODULE_FRAMEWORK_BASE_DIR, "core");
033
034 File[] files = coreDir.listFiles();
035
036 if (files == null) {
037 throw new IllegalStateException(
038 "Missing " + coreDir.getCanonicalPath());
039 }
040
041 URL[] urls = new URL[files.length];
042
043 for (int i = 0; i < urls.length; i++) {
044
045
046
047
048
049 String path = StringUtil.replace(
050 files[i].getAbsolutePath(), StringPool.BACK_SLASH,
051 StringPool.SLASH);
052
053 if (!path.startsWith(StringPool.SLASH)) {
054 path = StringPool.SLASH + path;
055 }
056
057 urls[i] = new URL("file", null, path);
058 }
059
060 return urls;
061 }
062
063 }