diff --git a/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java b/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java index 828167dc18..c567348c48 100644 --- a/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java +++ b/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java @@ -36,7 +36,7 @@ public class JNDIConfigUtil { private static Element getXmlRootElement() throws GenericConfigException { try { - return ResourceLoader.getXmlRootElement(JNDIConfigUtil.JNDI_CONFIG_XML_FILENAME); + return ResourceLoader.readXmlRootElement(JNDIConfigUtil.JNDI_CONFIG_XML_FILENAME); } catch (GenericConfigException e) { throw new GenericConfigException("Could not get JNDI XML root element", e); } diff --git a/framework/base/src/org/ofbiz/base/config/ResourceLoader.java b/framework/base/src/org/ofbiz/base/config/ResourceLoader.java index 7508dae803..7e2a13d86f 100644 --- a/framework/base/src/org/ofbiz/base/config/ResourceLoader.java +++ b/framework/base/src/org/ofbiz/base/config/ResourceLoader.java @@ -80,8 +80,10 @@ public abstract class ResourceLoader { return loader; } - // This method should be avoided. DOM object trees take a lot of memory and they are not - // thread-safe, so they should not be cached. + /** This method should be avoided. DOM object trees take a lot of memory and they are not + * thread-safe, so they should not be cached. + * @deprecated use {@link #readXmlRootElement(String)} + */ @Deprecated public static Element getXmlRootElement(String xmlFilename) throws GenericConfigException { Document document = ResourceLoader.getXmlDocument(xmlFilename); @@ -93,32 +95,30 @@ public abstract class ResourceLoader { } } + public static Element readXmlRootElement(String xmlFilename) throws GenericConfigException { + Document document = ResourceLoader.readXmlDocument(xmlFilename); + + if (document != null) { + return document.getDocumentElement(); + } else { + return null; + } + } + public static void invalidateDocument(String xmlFilename) throws GenericConfigException { UtilCache.clearCachesThatStartWith(xmlFilename); } - // This method should be avoided. DOM object trees take a lot of memory and they are not - // thread-safe, so they should not be cached. + /** This method should be avoided. DOM object trees take a lot of memory and they are not + * thread-safe, so they should not be cached. + * @deprecated use {@link #readXmlDocument(String)} + */ @Deprecated public static Document getXmlDocument(String xmlFilename) throws GenericConfigException { Document document = domCache.get(xmlFilename); if (document == null) { - URL confUrl = UtilURL.fromResource(xmlFilename); - - if (confUrl == null) { - throw new GenericConfigException("ERROR: could not find the [" + xmlFilename + "] XML file on the classpath"); - } - - try { - document = UtilXml.readXmlDocument(confUrl, true, true); - } catch (org.xml.sax.SAXException e) { - throw new GenericConfigException("Error reading " + xmlFilename + "", e); - } catch (javax.xml.parsers.ParserConfigurationException e) { - throw new GenericConfigException("Error reading " + xmlFilename + "", e); - } catch (java.io.IOException e) { - throw new GenericConfigException("Error reading " + xmlFilename + "", e); - } + document = readXmlDocument(xmlFilename); if (document != null) { document = (Document) domCache.putIfAbsentAndGet(xmlFilename, document); @@ -127,6 +127,24 @@ public abstract class ResourceLoader { return document; } + public static Document readXmlDocument(String xmlFilename) throws GenericConfigException { + URL confUrl = UtilURL.fromResource(xmlFilename); + + if (confUrl == null) { + throw new GenericConfigException("ERROR: could not find the [" + xmlFilename + "] XML file on the classpath"); + } + + try { + return UtilXml.readXmlDocument(confUrl, true, true); + } catch (org.xml.sax.SAXException e) { + throw new GenericConfigException("Error reading " + xmlFilename + "", e); + } catch (javax.xml.parsers.ParserConfigurationException e) { + throw new GenericConfigException("Error reading " + xmlFilename + "", e); + } catch (java.io.IOException e) { + throw new GenericConfigException("Error reading " + xmlFilename + "", e); + } + } + private static ResourceLoader makeLoader(Element loaderElement) throws GenericConfigException { String loaderName = loaderElement.getAttribute("name"); String className = loaderElement.getAttribute("class"); diff --git a/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java b/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java index 1eea41ff73..979d88ed75 100644 --- a/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java +++ b/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java @@ -52,7 +52,7 @@ public class ButtonEventConfig implements java.io.Serializable { protected boolean disableLock = false; public static void loadButtonConfig() throws GenericConfigException { - Element root = ResourceLoader.getXmlRootElement(ButtonEventConfig.BUTTON_EVENT_CONFIG); + Element root = ResourceLoader.readXmlRootElement(ButtonEventConfig.BUTTON_EVENT_CONFIG); List buttonEvents = UtilXml.childElementList(root, "event"); if (!UtilValidate.isEmpty(buttonEvents)) { Iterator i = buttonEvents.iterator();