You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by de...@apache.org on 2016/02/20 14:16:03 UTC
svn commit: r1731399 - in /ofbiz/trunk: ./
framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java
framework/base/src/org/ofbiz/base/config/ResourceLoader.java
specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java
Author: deepak
Date: Sat Feb 20 13:16:03 2016
New Revision: 1731399
URL: http://svn.apache.org/viewvc?rev=1731399&view=rev
Log:
OFBIZ-6278: Merged changes done at 1675464, 1675465 and 1675466 from OFBIZ-6275 branch to trunk.
Log:
==========================================================
- Make use of ResourceLoader.readXmlRootElement, which is
non-caching; this fixes a deprecation warning.
- Use ResourceLoader.readXmlRootElement, which is a
non-caching version. This fixes a deprecation warning.
- Provide method variants (readXml{Document,RootElement}) that contain the body of the deprecated methods (getXml{Document,RootElement}).
==========================================================
Modified:
ofbiz/trunk/ (props changed)
ofbiz/trunk/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java
ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceLoader.java
ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java
Propchange: ofbiz/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Feb 20 13:16:03 2016
@@ -1,5 +1,6 @@
/ofbiz/branches/2013_RemoveJavolution:1462755
/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23:1535171-1654698
+/ofbiz/branches/OFBIZ-6275:1675394-1675466
/ofbiz/branches/addbirt:831210-885099,885686-886087
/ofbiz/branches/boostrap_theme:1635411,1635439,1635465
/ofbiz/branches/dojo1.4:951708-952957
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java?rev=1731399&r1=1731398&r2=1731399&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java Sat Feb 20 13:16:03 2016
@@ -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);
}
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceLoader.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceLoader.java?rev=1731399&r1=1731398&r2=1731399&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceLoader.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceLoader.java Sat Feb 20 13:16:03 2016
@@ -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");
Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java?rev=1731399&r1=1731398&r2=1731399&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java (original)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java Sat Feb 20 13:16:03 2016
@@ -52,7 +52,7 @@ public class ButtonEventConfig implement
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();