Improved: General refactoring and code improvements, package

org.apache.ofbiz.base.component.
(OFBIZ-9872)

Thanks Dennis Balkir for reporting and providing the patches.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1817883 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Brohl
2017-12-12 06:26:29 +00:00
parent 3c8804772d
commit bae1848cd8
3 changed files with 20 additions and 17 deletions
@@ -47,7 +47,7 @@ import org.w3c.dom.Element;
/**
* An object that models the <code>&lt;ofbiz-component&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -458,8 +458,9 @@ public final class ComponentConfig {
} catch (ContainerException ce) {
throw new ComponentException("Error reading container configurations for component: " + this.globalName, ce);
}
if (Debug.verboseOn())
if (Debug.verboseOn()) {
Debug.logVerbose("Read component config : [" + rootLocation + "]", module);
}
}
public boolean enabled() {
@@ -596,7 +597,7 @@ public final class ComponentConfig {
/**
* An object that models the <code>&lt;classpath&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -619,7 +620,7 @@ public final class ComponentConfig {
private final Map<String, ComponentConfig> componentConfigs = new LinkedHashMap<>();
// Root location mapped to global name.
private final Map<String, String> componentLocations = new HashMap<>();
private synchronized ComponentConfig fromGlobalName(String globalName) {
return componentConfigs.get(globalName);
}
@@ -646,7 +647,7 @@ public final class ComponentConfig {
/**
* An object that models the <code>&lt;entity-resource&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -663,7 +664,7 @@ public final class ComponentConfig {
/**
* An object that models the <code>&lt;keystore&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -740,7 +741,7 @@ public final class ComponentConfig {
/**
* An object that models the <code>&lt;resource-loader&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -760,7 +761,7 @@ public final class ComponentConfig {
/**
* An object that models the <code>&lt;service-resource&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -775,7 +776,7 @@ public final class ComponentConfig {
/**
* An object that models the <code>&lt;test-suite&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -787,7 +788,7 @@ public final class ComponentConfig {
/**
* An object that models the <code>&lt;webapp&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -55,7 +55,7 @@ public final class ComponentLoaderConfig {
public static List<ComponentDef> getComponentsFromConfig(URL configUrl) throws ComponentException {
Document document = parseDocumentFromUrl(configUrl);
List<? extends Element> toLoad = UtilXml.childElementList(document.getDocumentElement());
List<ComponentDef> componentsFromConfig = new ArrayList<ComponentDef>();
List<ComponentDef> componentsFromConfig = new ArrayList<>();
for (Element element : toLoad) {
componentsFromConfig.add(retrieveComponentDefFromElement(element, configUrl));
@@ -18,15 +18,19 @@
*******************************************************************************/
package org.apache.ofbiz.base.component;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.ofbiz.base.config.GenericConfigException;
import org.apache.ofbiz.base.config.ResourceHandler;
import org.apache.ofbiz.base.util.Debug;
import org.apache.ofbiz.base.util.UtilXml;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
/**
* Contains resource information and provides for loading data
@@ -50,7 +54,9 @@ public class ComponentResourceHandler implements ResourceHandler {
this.componentName = componentName;
this.loaderName = loaderName;
this.location = location;
if (Debug.verboseOn()) Debug.logVerbose("Created " + this.toString(), module);
if (Debug.verboseOn()) {
Debug.logVerbose("Created " + this.toString(), module);
}
}
public String getLoaderName() {
@@ -64,11 +70,7 @@ public class ComponentResourceHandler implements ResourceHandler {
public Document getDocument() throws GenericConfigException {
try {
return UtilXml.readXmlDocument(this.getStream(), this.getFullLocation(), true);
} catch (org.xml.sax.SAXException e) {
throw new GenericConfigException("Error reading " + this.toString(), e);
} catch (javax.xml.parsers.ParserConfigurationException e) {
throw new GenericConfigException("Error reading " + this.toString(), e);
} catch (java.io.IOException e) {
} catch (SAXException | ParserConfigurationException | IOException e) {
throw new GenericConfigException("Error reading " + this.toString(), e);
}
}