cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1428656 - /cxf/branches/2.5.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
Date Thu, 03 Jan 2013 22:52:23 GMT
Author: dkulp
Date: Thu Jan  3 22:52:23 2013
New Revision: 1428656

URL: http://svn.apache.org/viewvc?rev=1428656&view=rev
Log:
Merged revisions 1428406 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

........
  r1428406 | dkulp | 2013-01-03 10:38:52 -0500 (Thu, 03 Jan 2013) | 10 lines

  Merged revisions 1428398 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk

  ........
    r1428398 | dkulp | 2013-01-03 10:23:09 -0500 (Thu, 03 Jan 2013) | 2 lines

    Bunch of optimizations for the Aegis XMLTypeCreator to delay creating the XPathUtils and
to cache which documents could NOT be found instead of trying to repeatedly find it.

  ........

........

Modified:
    cxf/branches/2.5.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java

Modified: cxf/branches/2.5.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java?rev=1428656&r1=1428655&r2=1428656&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
Thu Jan  3 22:52:23 2013
@@ -135,7 +135,13 @@ public class XMLTypeCreator extends Abst
         }
     }
     
-    private XPathUtils xpathUtils = new XPathUtils();
+    private volatile XPathUtils xpathUtils;
+    private synchronized XPathUtils getXPathUtils() {
+        if (xpathUtils == null) {
+            xpathUtils = new XPathUtils();
+        }
+        return xpathUtils;
+    }
 
     private Document readAegisFile(InputStream is, final String path) throws IOException
{
         DocumentBuilder documentBuilder;
@@ -195,23 +201,24 @@ public class XMLTypeCreator extends Abst
         if (clazz == null) {
             return null;
         }
-        Document doc = documents.get(clazz.getName());
-        if (doc != null) {
-            return doc;
+        if (documents.containsKey(clazz.getName())) {
+            return documents.get(clazz.getName());
         }
         String path = '/' + clazz.getName().replace('.', '/') + ".aegis.xml";
         InputStream is = clazz.getResourceAsStream(path);
         if (is == null) {
+            documents.put(clazz.getName(), null);
             LOG.finest("Mapping file : " + path + " not found.");
             return null;
         }
         LOG.finest("Found mapping file : " + path);
         try {
-            doc = readAegisFile(is, path);
+            Document doc = readAegisFile(is, path);
             documents.put(clazz.getName(), doc);
             return doc;
         } catch (IOException e) {
             LOG.log(Level.SEVERE, "Error loading file " + path, e);
+            documents.put(clazz.getName(), null);
             return null;
         }
     }
@@ -714,11 +721,11 @@ public class XMLTypeCreator extends Abst
     }
 
     private Element getMatch(Node doc, String xpath) {
-        return (Element)xpathUtils.getValue(xpath, doc, XPathConstants.NODE);
+        return (Element)getXPathUtils().getValue(xpath, doc, XPathConstants.NODE);
     }
 
     private List<Element> getMatches(Node doc, String xpath) {
-        NodeList nl = (NodeList)xpathUtils.getValue(xpath, doc, XPathConstants.NODESET);
+        NodeList nl = (NodeList)getXPathUtils().getValue(xpath, doc, XPathConstants.NODESET);
         List<Element> r = new ArrayList<Element>();
         for (int x = 0; x < nl.getLength(); x++) {
             r.add((Element)nl.item(x));



Mime
View raw message