File tree Expand file tree Collapse file tree
core/src/main/java/com/ocpsoft/pretty/faces/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,32 +38,41 @@ public class JAXBPrettyConfigParser implements PrettyConfigParser
3838
3939 private final static String JAXB_CLASS_PACKAGE = "com.ocpsoft.pretty.faces.config.types" ;
4040
41- private JAXBContext jaxbContext ;
42-
43- private SAXParserFactory saxParserFactory ;
41+ private final static JAXBContext jaxbContext ;
42+
43+ private final SAXParserFactory saxParserFactory ;
4444
4545 private Schema schema ;
4646
4747 /**
48- * Constructor
48+ * We do this expensive operations here. This should
49+ * be OK as we do it once per ClassLoader.
4950 */
50- public JAXBPrettyConfigParser ()
51+ static
5152 {
5253 try
5354 {
5455 // build JAXBContext using the package we generate the classes to
5556 jaxbContext = JAXBContext .newInstance (JAXB_CLASS_PACKAGE );
5657
57- // create a namespace aware SAXParserFactory
58- saxParserFactory = SAXParserFactory .newInstance ();
59- saxParserFactory .setNamespaceAware (true );
60-
6158 }
6259 catch (JAXBException e )
6360 {
6461 throw new IllegalStateException (e );
6562 }
6663 }
64+
65+ /**
66+ * Creates a new {@link JAXBPrettyConfigParser}
67+ */
68+ public JAXBPrettyConfigParser ()
69+ {
70+
71+ // SAXParserFactory is NOT thread-safe
72+ saxParserFactory = SAXParserFactory .newInstance ();
73+ saxParserFactory .setNamespaceAware (true );
74+
75+ }
6776
6877 /*
6978 * @see
You can’t perform that action at this time.
0 commit comments