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