use of org.apache.ofbiz.base.component.ComponentConfig in project ofbiz-framework by apache.
the class ComponentContainer method loadComponentsInDirectory.
/**
* Load all components in a directory because it does not contain
* a load-components.xml file. The components are sorted alphabetically
* for loading purposes
*
* @param directoryPath the absolute path of the directory
* @throws IOException
*/
private void loadComponentsInDirectory(File directoryPath) throws IOException {
String[] sortedComponentNames = directoryPath.list();
if (sortedComponentNames == null) {
throw new IllegalArgumentException("sortedComponentNames is null, directory path is invalid " + directoryPath.getPath());
}
Arrays.sort(sortedComponentNames);
for (String componentName : sortedComponentNames) {
File componentPath = FileUtil.getFile(directoryPath.getCanonicalPath() + File.separator + componentName);
String componentLocation = componentPath.getCanonicalPath();
File configFile = FileUtil.getFile(componentLocation.concat(File.separator).concat(ComponentConfig.OFBIZ_COMPONENT_XML_FILENAME));
if (componentPath.isDirectory() && !componentName.startsWith(".") && configFile.exists()) {
ComponentConfig config = retrieveComponentConfig(null, componentLocation);
if (config != null) {
loadComponent(config);
}
}
}
}
use of org.apache.ofbiz.base.component.ComponentConfig in project ofbiz-framework by apache.
the class ComponentContainer method buildClasspathFromComponentConfig.
/**
* Construct a <code>Classpath</code> object for a certain component based
* on its configuration defined in <code>ComponentConfig</code>
*
* @param config the component configuration
* @return the constructed classpath
* @throws IOException
*/
private Classpath buildClasspathFromComponentConfig(ComponentConfig config) throws IOException {
Classpath classPath = new Classpath();
String configRoot = config.getRootLocation().replace('\\', '/');
configRoot = configRoot.endsWith("/") ? configRoot : configRoot + "/";
List<ComponentConfig.ClasspathInfo> classpathInfos = config.getClasspathInfos();
for (ComponentConfig.ClasspathInfo cp : classpathInfos) {
String location = cp.location.replace('\\', '/');
if (!"jar".equals(cp.type) && !"dir".equals(cp.type)) {
Debug.logError("Classpath type '" + cp.type + "' is not supported; '" + location + "' not loaded", module);
continue;
}
location = location.startsWith("/") ? location.substring(1) : location;
String dirLoc = location.endsWith("/*") ? location.substring(0, location.length() - 2) : location;
File path = FileUtil.getFile(configRoot + dirLoc);
if (path.exists()) {
classPath.addComponent(configRoot + location);
if (path.isDirectory() && "dir".equals(cp.type)) {
classPath.addFilesFromPath(path);
}
} else {
Debug.logWarning("Location '" + configRoot + dirLoc + "' does not exist", module);
}
}
return classPath;
}
Aggregations