logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject RE: Acorn Progress
Date Tue, 08 Apr 2003 23:29:50 GMT

You could try something like this...

     /**
      * create SAX2 Parser (XMLReader) instance.  Attempts to load the 
passed-in
      * preferred parser first. If that fails, it falls back to loading the
      * parser set by the org.xml.sax.driver property. Failing that, other 
known
      * parsers are explicitly attempted for loading. If that fails, you are
      * trying really hard to defeat this method!
      *
      * @param preferred the preferred parser name, may be null
      * @return an XMLReader, guaranteed non-null
      * @throws SAXException when no SAX2 Parser is available
      */
     private XMLReader getXMLReader(String preferred) throws SAXException {
         XMLReader parser = null;
         try { // Preferred
             if (preferred != null) {
                 parser = XMLReaderFactory.createXMLReader(preferred);
             } else {
                 throw new SAXException("Preferred SAX parser unavailable!");
             }
         }
         catch (SAXException e1) {
             try { // default
                 // obtain parser via system property...
                 // loads whatever parser was set in the system property
                 // org.xml.sax.driver and will also fall back to the SAX1
                 // system property org.xml.sax.parser
                 parser = XMLReaderFactory.createXMLReader();
             }
             catch (SAXException e2) {
                 try { // Piccolo (speed demon: 
http://piccolo.sourceforge.net/bench.html -- non-validating, but can be 
wrapped by a validating parser)
                     parser = 
XMLReaderFactory.createXMLReader("com.bluecast.xml.Piccolo");
                 }
                 catch (SAXException e3) {
                     try { // Xerces (the standard)
                         parser = 
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
                     }
                     catch (SAXException e4) {
                         try { // Crimson (exists in j2sdk1.4.x)
                             parser = 
XMLReaderFactory.createXMLReader("org.apache.crimson.parser.XMLReaderImpl");
                         }
                         catch (SAXException e5) {
                             try { // Ælfred (optionally validating)
                                 parser = 
XMLReaderFactory.createXMLReader("gnu.xml.aelfred2.XmlReader");
                             }
                             catch (SAXException e6) {
                                 try { // older Ælfred (non-validating)
                                 parser = 
XMLReaderFactory.createXMLReader("net.sf.saxon.aelfred.SAXDriver");
                                 }
                                 catch (SAXException e7) {
                                     // Oracle (well, why not?) ...last 
ditch attempt, let the exception go after this
                                     parser = 
XMLReaderFactory.createXMLReader("oracle.xml.parser.v2.SAXParser");
                                 }
                             }
                         }
                     }
                 }
             }
         }
         return parser;
     }

Jake

At 05:14 PM 4/8/2003 -0600, you wrote:
>Thanks for the feedback Paul.  We'll see if we can't replace your xml
>editor for you :-)
>
>Does anybody have any good code for searching for a factory implementation
>-- like how javax.xml.parsers.SAXParserFactory.newSaxParser() works?  I
>think apache has a project for doing this (discovery?).  This is one part
>of the picture that I have yet to implement 'cause I don't want to
>reinvent the wheel here.
>
>Thanks,
>Richard
>
>
>
>
>Paul Smith <Paul.Smith@lawlex.com.au>
>04/08/2003 04:42 PM
>Please respond to "Log4J Developers List"
>
>         To:     'Log4J Developers List' <log4j-dev@jakarta.apache.org>
>         cc:
>         Subject:        RE: Acorn Progress
>
>
>Neat, I really like it's simplicity.  My trial version of XMLSpy is about
>to
>run out, and our company isn't going to fork out for a licence by the
>looks
>of it, so I'm back to Textpad or Cooktop.  I'm keen to have a nice Log4j
>editor asap! :)
>
>Paul Smith
>
> > -----Original Message-----
> > From: Richard Bair [mailto:rbair23@yahoo.com]
> > Sent: Wednesday, 9 April 2003 3:43 AM
> > To: log4j
> > Subject: Acorn Progress
> >
> >
> > Hey Everyone,
> >
> > I'm sure not getting much time to work on this, but
> > slow and steady wins the race, right? :-)
> >
> > Attached is a screenshot of where I'm at right now.
> > You can see the basic idea.  I think using a JList
> > like this is a little unconventional, but I didn't
> > like the idea of using two JLists etc.  Just playing
> > around a little bit there.
> >
> > Also, I'm reading XML config files just fine here.
> > Its really a suprisingly compact piece of code so far.
> >  I still have a long way to go!
> >
> > Sorry about the size/quality of that image, maybe its
> > time I download some better image product than Paint.
> >
> > Cheers,
> > Richard
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Tax Center - File online, calculators, forms, and more
> > http://tax.yahoo.com
> >
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-dev-help@jakarta.apache.org

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message