]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2314: Caching xmlParserClassName in org.apache.fop.svg.SimpleSVGUserAgent; patch...
authorLuis Bernardo <lbernardo@apache.org>
Sun, 24 Nov 2013 00:57:26 +0000 (00:57 +0000)
committerLuis Bernardo <lbernardo@apache.org>
Sun, 24 Nov 2013 00:57:26 +0000 (00:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1544897 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/svg/SimpleSVGUserAgent.java

index 2b27945a45fa26f51b038b65e85ca5dde3c02e50..132c633dc1f0c112ee2024e41ed0899c19928683 100644 (file)
@@ -23,8 +23,11 @@ import java.awt.Dimension;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Dimension2D;
 
+import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParserFactory;
 
+import org.xml.sax.SAXException;
+
 import org.apache.batik.bridge.UserAgentAdapter;
 
 /**
@@ -79,17 +82,28 @@ public class SimpleSVGUserAgent extends UserAgentAdapter {
         return null; // userStyleSheetURI;
     }
 
+
+    private static final String XML_PARSER_CLASS_NAME;
+
+    static {
+        String result;
+        try {
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            result = factory.newSAXParser().getXMLReader().getClass().getName();
+        } catch (SAXException e) {
+            result = null;
+        } catch (ParserConfigurationException e) {
+            result = null;
+        }
+        XML_PARSER_CLASS_NAME = result;
+    }
+
     /**
      * Returns the class name of the XML parser.
      * @return the XML parser class name
      */
     public String getXMLParserClassName() {
-        try {
-            SAXParserFactory factory = SAXParserFactory.newInstance();
-            return factory.newSAXParser().getXMLReader().getClass().getName();
-        } catch (Exception e) {
-            return null;
-        }
+        return XML_PARSER_CLASS_NAME;
     }
 
     /**