You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2013/01/20 11:58:25 UTC

svn commit: r1435815 - /tomee/tomee/trunk/container/openejb-jee-accessors/src/main/java/org/apache/openejb/sxc/Sxc.java

Author: rmannibucau
Date: Sun Jan 20 10:58:25 2013
New Revision: 1435815

URL: http://svn.apache.org/viewvc?rev=1435815&view=rev
Log:
trying to force jvm implementation first and skip SPI mecanism. If it doesn't work just use the default one

Modified:
    tomee/tomee/trunk/container/openejb-jee-accessors/src/main/java/org/apache/openejb/sxc/Sxc.java

Modified: tomee/tomee/trunk/container/openejb-jee-accessors/src/main/java/org/apache/openejb/sxc/Sxc.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-jee-accessors/src/main/java/org/apache/openejb/sxc/Sxc.java?rev=1435815&r1=1435814&r2=1435815&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-jee-accessors/src/main/java/org/apache/openejb/sxc/Sxc.java (original)
+++ tomee/tomee/trunk/container/openejb-jee-accessors/src/main/java/org/apache/openejb/sxc/Sxc.java Sun Jan 20 10:58:25 2013
@@ -173,11 +173,17 @@ public class Sxc {
         try {
             // We don't want to use whatever they have put in the their app as a STAX impl
             Thread.currentThread().setContextClassLoader(Sxc.class.getClassLoader());
-            final XMLInputFactory factory = XMLInputFactory.newInstance();
+            XMLInputFactory factory = null;
+            try { // 1) trying to force jvm one, 2) skipping classloading/SPI mecanism, 3) setting specific property
+                factory = (XMLInputFactory) Sxc.class.getClassLoader()
+                        .loadClass("com.sun.xml.internal.stream.XMLInputFactoryImpl").newInstance();
+                factory.setProperty("http://java.sun.com/xml/stream/properties/ignore-external-dtd", Boolean.TRUE);
+            } catch (Exception e) { // not a big deal, using the default one
+                factory = XMLInputFactory.newInstance();
+            }
             factory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
             factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
             factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
-            factory.setProperty("http://java.sun.com/xml/stream/properties/ignore-external-dtd", Boolean.TRUE);
             return factory;
         } finally {
             Thread.currentThread().setContextClassLoader(contextClassLoader);



Re: svn commit: r1435815 - /tomee/tomee/trunk/container/openejb-jee-accessors/src/main/java/org/apache/openejb/sxc/Sxc.java

Posted by Romain Manni-Bucau <rm...@gmail.com>.
the idea os the classloader switching is to use the jvm one which is fast
(David benched IIRC)

using the newInstance() method has 2 drawbacks:
1) in embedded mode it doesn't work (single big classpath)
2) we go through the SPI mecanism even if 8/10 times we know the result

open to discuss further if you see some reason to not do this change

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/1/20 Jacek Laskowski <ja...@japila.pl>

> On Sun, Jan 20, 2013 at 11:58 AM,  <rm...@apache.org> wrote:
> > trying to force jvm one
>
> Why is this important?
>
> Jacek
>
> --
> Jacek Laskowski
> Functional languages (Clojure), Java EE, and IBM WebSphere -
> http://blog.japila.pl
> "Never discourage anyone who continually makes progress, no matter how
> slow." Plato
>

Re: svn commit: r1435815 - /tomee/tomee/trunk/container/openejb-jee-accessors/src/main/java/org/apache/openejb/sxc/Sxc.java

Posted by Jacek Laskowski <ja...@japila.pl>.
On Sun, Jan 20, 2013 at 11:58 AM,  <rm...@apache.org> wrote:
> trying to force jvm one

Why is this important?

Jacek

-- 
Jacek Laskowski
Functional languages (Clojure), Java EE, and IBM WebSphere -
http://blog.japila.pl
"Never discourage anyone who continually makes progress, no matter how
slow." Plato