本文整理匯總了Java中org.ofbiz.base.component.ComponentConfig.getClasspathInfos方法的典型用法代碼示例。如果您正苦於以下問題:Java ComponentConfig.getClasspathInfos方法的具體用法?Java ComponentConfig.getClasspathInfos怎麽用?Java ComponentConfig.getClasspathInfos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.ofbiz.base.component.ComponentConfig
的用法示例。
在下文中一共展示了ComponentConfig.getClasspathInfos方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadComponent
import org.ofbiz.base.component.ComponentConfig; //導入方法依賴的package包/類
private void loadComponent(ComponentConfig config) {
// make sure the component is enabled
if (!config.enabled()) {
Debug.logInfo("Not Loading component : [" + config.getComponentName() + "] (disabled)", module);
return;
}
Debug.logInfo("Loading component : [" + config.getComponentName() + "]", module);
List<ComponentConfig.ClasspathInfo> classpathInfos = config.getClasspathInfos();
String configRoot = config.getRootLocation();
configRoot = configRoot.replace('\\', '/');
// set the root to have a trailing slash
if (!configRoot.endsWith("/")) {
configRoot = configRoot + "/";
}
if (classpathInfos != null) {
String nativeLibExt = System.mapLibraryName("someLib").replace("someLib", "").toLowerCase();
for (ComponentConfig.ClasspathInfo cp: classpathInfos) {
String location = cp.location.replace('\\', '/');
// set the location to not have a leading slash
if (location.startsWith("/")) {
location = location.substring(1);
}
if (!"jar".equals(cp.type) && !"dir".equals(cp.type)) {
Debug.logError("Classpath type '" + cp.type + "' is not supported; '" + location + "' not loaded", module);
continue;
}
String dirLoc = location;
if (dirLoc.endsWith("/*")) {
// strip off the slash splat
dirLoc = location.substring(0, location.length() - 2);
}
File path = FileUtil.getFile(configRoot + dirLoc);
if (path.exists()) {
if (path.isDirectory()) {
if ("dir".equals(cp.type)) {
classPath.addComponent(configRoot + location);
}
// load all .jar, .zip files and native libs in this directory
boolean containsNativeLibs = false;
for (File file: path.listFiles()) {
String fileName = file.getName().toLowerCase();
if (fileName.endsWith(".jar") || fileName.endsWith(".zip")) {
classPath.addComponent(file);
} else if (fileName.endsWith(nativeLibExt)) {
containsNativeLibs = true;
}
}
if (containsNativeLibs) {
libraryPath.addComponent(path);
}
} else {
// add a single file
classPath.addComponent(configRoot + location);
}
} else {
Debug.logWarning("Location '" + configRoot + dirLoc + "' does not exist", module);
}
}
}
}