Reverted: General refactoring and code improvements, package

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

The patches were modified to remove Debug.is[Loglevel]On()
conditions. It is better to keep them for better runtime performance.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1817882 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Brohl
2017-12-12 06:24:37 +00:00
parent 8100a6569e
commit 3c8804772d
3 changed files with 18 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,7 +458,8 @@ public final class ComponentConfig {
} catch (ContainerException ce) {
throw new ComponentException("Error reading container configurations for component: " + this.globalName, ce);
}
Debug.logVerbose("Read component config : [" + rootLocation + "]", module);
if (Debug.verboseOn())
Debug.logVerbose("Read component config : [" + rootLocation + "]", module);
}
public boolean enabled() {
@@ -595,7 +596,7 @@ public final class ComponentConfig {
/**
* An object that models the <code>&lt;classpath&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -618,7 +619,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);
}
@@ -645,7 +646,7 @@ public final class ComponentConfig {
/**
* An object that models the <code>&lt;entity-resource&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -662,7 +663,7 @@ public final class ComponentConfig {
/**
* An object that models the <code>&lt;keystore&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -739,7 +740,7 @@ public final class ComponentConfig {
/**
* An object that models the <code>&lt;resource-loader&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -759,7 +760,7 @@ public final class ComponentConfig {
/**
* An object that models the <code>&lt;service-resource&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -774,7 +775,7 @@ public final class ComponentConfig {
/**
* An object that models the <code>&lt;test-suite&gt;</code> element.
*
*
* @see <code>ofbiz-component.xsd</code>
*
*/
@@ -786,7 +787,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<>();
List<ComponentDef> componentsFromConfig = new ArrayList<ComponentDef>();
for (Element element : toLoad) {
componentsFromConfig.add(retrieveComponentDefFromElement(element, configUrl));
@@ -18,19 +18,15 @@
*******************************************************************************/
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
@@ -54,7 +50,7 @@ public class ComponentResourceHandler implements ResourceHandler {
this.componentName = componentName;
this.loaderName = loaderName;
this.location = location;
Debug.logVerbose("Created " + this.toString(), module);
if (Debug.verboseOn()) Debug.logVerbose("Created " + this.toString(), module);
}
public String getLoaderName() {
@@ -68,7 +64,11 @@ public class ComponentResourceHandler implements ResourceHandler {
public Document getDocument() throws GenericConfigException {
try {
return UtilXml.readXmlDocument(this.getStream(), this.getFullLocation(), true);
} catch (SAXException | ParserConfigurationException | IOException e) {
} 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) {
throw new GenericConfigException("Error reading " + this.toString(), e);
}
}