____________________________
Mark E. Cornelius
Phi Beta Sigma/Prince Hall Mason
The Woodlands, Texas

I had fainted, unless I had believed to see the goodness of the LORD
in the land of  the living.  Wait on the LORD:  be of good courage, and he
shall strengthen thine
heart: wait, I say, on the LORD. "

   Psalms 27:13-14

----- Original Message -----
From: "Keith Visco" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 14, 2003 5:32 PM
Subject: Re: [castor-dev] 5 times the performance patch(config irrelevant)


>
> Hi Dean, Mickael,
>
> The best thing to do is open up a bugzilla enhancement request so we can
> track it. I'll review the patch once I have a chance.
>
> Thanks,
>
> --Keith
>
> Dean Hiller wrote:
> >
> > that works too, keith what are the chances we can get this fix in soon?
> > thanks,
> > dean
> >
> > Micka�l Guessant wrote:
> >
> > > Another way to solve this would be to isolate the SAXParserFactory
> > > in a separate class => this class will only get loaded if
> > > javax.xml.parsers.SAXParser is specified.
> > >
> > > if("javax.xml.parsers.SAXParser".equals(prop)) {
> > >  reader = LocalSAXParserFactory.getParser();
> > > }
> > >
> > > with
> > > class LocalSAXParserFactory {
> > >   static XMLReader = getParser() throws ??? {
> > >     javax.xml.parsers.SAXParserFactory saxParserFactory =
> > > javax.xml.parsers.SAXParserFactory.newInstance();
> > >             javax.xml.parsers.SAXParser saxParser =
> > >      saxParserFactory.newSAXParser();
> > >              return saxParser.getXMLReader();
> > >   }
> > > }
> > >
> > > You only need to add jaxp.jar and a JAXP compliant parser to
> > > the CLASSPATH to make this work.
> > >
> > > Dean Hiller wrote:
> > >
> > >> If I am not mistaken, this would break compilation with jdk1.3 which
> > >> is why I requested a setParser() method on
> > >> LocalConfiguration, as opposed to what you are asking for.   Now that
> > >> you mention it though, that could be turned into a bunch of
> > >> reflection like so
> > >>
> > >> if("javax.xml.parsers.SAXParser".equals(prop)) {
> > >>     Class factoryClass =
> > >> Class.forName("javax.xml.parsers.SAXParserFactory");
> > >>     Method getFactoryMethod = factoryClass.getMethod("newInstance");
> > >>     Object factory = getParserMethod.invoke(null, null);
> > >>     //now we have the factory
> > >>     Method getParserMethod = factoryClass.getMethod("newParser");
> > >>      Object parser = getParserMethod.invoke(factory, null);
> > >> //now we have the parser.
> > >>
> > >> thanks Micka�l for going down that road.
> > >>
> > >> Keith can you commit something like this(Be warned, I didn't test it
> > >> yet, but Method class states it can do static methods to).  thanks,
> > >> Dean
> > >>
> > >> Micka�l Guessant wrote:
> > >>
> > >>> Hi all,
> > >>>
> > >>> Attached is a patch trying to improve SAX Parser creation
> > >>> code. When JAXP is requested, use the SAXParserFactory :
> > >>>
> > >>> >           if ("javax.xml.parsers.SAXParser".equals(prop)) {
> > >>> >             javax.xml.parsers.SAXParserFactory saxParserFactory =
> > >>> >                 javax.xml.parsers.SAXParserFactory.newInstance();
> > >>> >             javax.xml.parsers.SAXParser saxParser =
> > >>> saxParserFactory.newSAXParser();
> > >>> >             reader = saxParser.getXMLReader();
> > >>>
> > >>> I also updated the code to handle the case when the class
> > >>> implements XMLReader but not SAXParser.
> > >>>
> > >>> The same code is present in the Configuration class, we could
> > >>> use an internalGetParser to avoid duplicate code.
> > >>>
> > >>> We may also convert everything to SAX2, and use an adapter
> > >>> for backward compatibility ?
> > >>>
> > >>> Any comments ?
> > >>>
> > >>> Dean Hiller wrote:
> > >>>
> > >>>> Some more performance baby....
> > >>>>
> > >>>> Just add a setParser() method to LocalConfiguration.java for me
> > >>>> please.  Then the way to improve performance by 5 times is below.
> > >>>> No it is a not a matter of setting the parser property in config
> > >>>> because javax.xml.parsers.SAXParser does not have a null
constructor!
> > >>>>
> > >>>> I went back and looked at why I get 5 times performance improvement
> > >>>> when I started using javax.xml.parsers.SAXParser.  The performance
> > >>>> improvement appears to be purely the parser is better and faster
> > >>>> than the xerces one used for small messages(around 200 bytes
> > >>>> each).(I commented out all configuration in the comparison).  This
> > >>>> means we need flexibility to choose parsers which is not there(see
> > >>>> below for why).
> > >>>>
> > >>>> Issues to be considered during the patch
> > >>>> --------------------------------------------------
> > >>>> Unfortunately, the castor LocalConfiguration.java has no setParser
> > >>>> method on it, and instantiates the parser only if it has a null
> > >>>> constructor.  Guess what, *javax.xml.parsers.SAXParser does not
> > >>>> have a null constructor.*  In 1.4, you are not even supposed to
> > >>>> instantiate it directly, rather you are supposed to go through the
> > >>>> factory.  On top of this, I believe castor supports 1.3 which
> > >>>> doesn't even have the SAXParserFactory interface for instantiating
> > >>>> parsers.  I think the best method would be to put a setParser
> > >>>> method on LocalConfiguration.java.  It is a quick and easy patch I
> > >>>> believe.  The only thing is you will get the same parser back every
> > >>>> time you call getParser().   The Unmarshaller calls getParser().
> > >>>> The other method might be to add setParser on the Unmarshaller and
> > >>>> Marshaller???  Anything is fine with me, I just need this quick
> > >>>> little change.
> > >>>> thanks,
> > >>>> Dean
> > >>>>
> > >>>>
> > >>>
> > >>>
> >
>>> ------------------------------------------------------------------------
> > >>>
> > >>>
> > >>> Index: src/main/org/exolab/castor/util/LocalConfiguration.java
> > >>> ===================================================================
> > >>> RCS file:
> > >>>
/cvs/castor/castor/src/main/org/exolab/castor/util/LocalConfiguration.java,v
> > >>>
> > >>> retrieving revision 1.6
> > >>> diff -w -b -r1.6 LocalConfiguration.java
> > >>> 64a65
> > >>>
> > >>>
> > >>>> import org.xml.sax.helpers.XMLReaderAdapter;
> > >>>>
> > >>>
> > >>> 273c274,275
> > >>> <         Parser parser;
> > >>> ---
> > >>>
> > >>>
> > >>>>        Parser parser = null;
> > >>>>        XMLReader reader = null;
> > >>>>
> > >>>
> > >>> 283a286,293
> > >>>
> > >>>
> > >>>>          if ("javax.xml.parsers.SAXParser".equals(prop)) {
> > >>>>            javax.xml.parsers.SAXParserFactory saxParserFactory =
> > >>>>                javax.xml.parsers.SAXParserFactory.newInstance();
> > >>>>            javax.xml.parsers.SAXParser saxParser =
> > >>>> saxParserFactory.newSAXParser();
> > >>>>            reader = saxParser.getXMLReader();
> > >>>>
> > >>>>          } else {
> > >>>>
> > >>>>
> > >>>
> > >>> 287,289c297,313
> > >>> <             parser = (Parser) cls.newInstance();
> > >>> <         } catch ( Exception except ) {
> > >>> <             throw new RuntimeException( Messages.format(
> > >>> "conf.failedInstantiateParser",
> > >>> ---
> > >>>
> > >>>
> > >>>>            Object anObject = cls.newInstance();
> > >>>>            if (anObject instanceof XMLReader) {
> > >>>>              reader = (XMLReader)anObject;
> > >>>>            }
> > >>>>            if (anObject instanceof Parser) {
> > >>>>              parser = (Parser)anObject;
> > >>>>            }
> > >>>>            if ((reader != null) &&
> > >>>>                (parser == null)) {
> > >>>>                parser = new XMLReaderAdapter(reader);
> > >>>>            }
> > >>>>            if (parser == null) throw new ClassCastException();
> > >>>>          }
> > >>>>        }
> > >>>>        catch (Exception except) {
> > >>>>          throw new RuntimeException(Messages.format(
> > >>>>              "conf.failedInstantiateParser",
> > >>>>
> > >>>
> > >>> 293c317
> > >>> <         if ( parser instanceof XMLReader ) {
> > >>> ---
> > >>>
> > >>>
> > >>>>        if ( reader != null ) {
> > >>>>
> > >>>
> > >>> 300c324
> > >>> <                 ( (XMLReader) parser ).setFeature(
> > >>> Features.Validation, flag );
> > >>> ---
> > >>>
> > >>>
> > >>>>                reader.setFeature( Features.Validation, flag );
> > >>>>
> > >>>
> > >>> 307c331
> > >>> <                 ( (XMLReader) parser ).setFeature(
> > >>> Features.Namespaces, flag );
> > >>> ---
> > >>>
> > >>>
> > >>>>                reader.setFeature( Features.Namespaces, flag );
> > >>>>
> > >>>
> > >>> 317c341
> > >>> <                         ( (XMLReader) parser ).setFeature(
> > >>> token.nextToken(), true );
> > >>> ---
> > >>>
> > >>>
> > >>>>                        reader.setFeature( token.nextToken(),
true );
> > >>>>
> > >>>
> > >>
> > >
> > >
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-dev
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to