[jboss-svn-commits] JBL Code SVN: r30953 - in labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb: util and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jan 5 23:26:45 EST 2010


Author: beve
Date: 2010-01-05 23:26:44 -0500 (Tue, 05 Jan 2010)
New Revision: 30953

Added:
   labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/util/DOMUtil.java
   labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/util/TransformerUtil.java
Modified:
   labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/helpers/ConfigTree.java
Log:
Work for https://jira.jboss.org/jira/browse/JBESB-3093 "ConfigTree's toXml method creates a new TransformerFactory and DocumentBuilderFactory upon every invocation"


Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/helpers/ConfigTree.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/helpers/ConfigTree.java	2010-01-06 03:13:03 UTC (rev 30952)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/helpers/ConfigTree.java	2010-01-06 04:26:44 UTC (rev 30953)
@@ -38,18 +38,18 @@
 import java.util.Set;
 
 import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.util.DOMUtil;
+import org.jboss.soa.esb.util.TransformerUtil;
 import org.jboss.internal.soa.esb.assertion.AssertArgument;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -71,7 +71,7 @@
 public class ConfigTree implements Serializable, Cloneable {
 
     private static Logger logger = Logger.getLogger(ConfigTree.class);
-
+    
     private static final long serialVersionUID = 1L;
 
     /**
@@ -556,7 +556,7 @@
             throw new IllegalArgumentException();
         DocumentBuilder builder = null;
         try {
-            builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+            builder = DOMUtil.getDocuementBuilderFactory().newDocumentBuilder();
         }
         catch (ParserConfigurationException e2) {
             _logger.error("Problems with default Parser Configuration", e2);
@@ -650,7 +650,7 @@
     public String toXml(String encoding) {
         Transformer transf = null;
         try {
-            transf = TransformerFactory.newInstance().newTransformer();
+            transf = TransformerUtil.getTransformerFactory().newTransformer();
         }
         catch (TransformerConfigurationException e1) {
             _logger.error("Cannot obtain transformer to render XML output", e1);
@@ -662,7 +662,7 @@
 
         DocumentBuilder builder = null;
         try {
-            builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+            builder = DOMUtil.getDocuementBuilderFactory().newDocumentBuilder();
         }
         catch (ParserConfigurationException e2) {
             _logger.error("Problems with default Parser Configuration", e2);

Added: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/util/DOMUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/util/DOMUtil.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/util/DOMUtil.java	2010-01-06 04:26:44 UTC (rev 30953)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.util;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+/**
+ * Util class for methods related to DOM processing.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class DOMUtil
+{
+    private static final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
+    
+    private DOMUtil()
+    {
+    }
+    
+    public static DocumentBuilderFactory getDocuementBuilderFactory()
+    {
+        return DOCUMENT_BUILDER_FACTORY;
+    }
+
+}

Added: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/util/TransformerUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/util/TransformerUtil.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/util/TransformerUtil.java	2010-01-06 04:26:44 UTC (rev 30953)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.util;
+
+import javax.xml.transform.TransformerFactory;
+
+/**
+ * Util class for transformation related tasks.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class TransformerUtil
+{
+	private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();
+	
+    private TransformerUtil()
+    {
+    }
+    
+    public static TransformerFactory getTransformerFactory()
+    {
+        return TRANSFORMER_FACTORY;
+    }
+
+}



More information about the jboss-svn-commits mailing list