[JDEV] Question on using NIO with SAX

David Waite mass at akuma.org
Thu Mar 21 19:16:00 CST 2002


This is an issue with the SAX Api (which understandably, we can't 
change). What you want is a push-model parser (like SAX) which takes a 
block of bytes/characters and calls events on the DocumentHandler (on 
that thread) until that block of data has been processed, then returns 
or saves the remainder until the next time it is passed.  SAX does not 
define this, and anything which does this at least is extending SAX.

I believe Xerces-J at least defines a parseSome method on its XmlParser 
method, but I don't know if this does what you want.

-David Waite

Chan, Oscar wrote:

> Hi all,
>
> I am new here.  I am now developing a message server based on the 
> subset of Jabber protocol. I am building using Java, and SAX parser in 
> javax.xml.parsers package.   My problem is that I am trying to code 
> the server so that it can use NIO (new i/o) package once java 1.4 is 
> stable enough to use.  By using NIO, it eliminates the problem of 
> having a thread per socket because it multiplexes the input and store 
> the data in a buffer instead of blocking the call and waiting until 
> data is available.  Usually, the server machine will slow down when 
> the number of thread reach about 1000.  Therefore, NIO will increase 
> the number of connection that we can have. 
>
> Since parse() method in java.xml.parsers.SAXParser is using a blocking 
> I/O and, hence, it increase the number of threads. Does anyone know 
> any workaround for it, or any future support for SAX using NIO?
>
> Thanks
>
> Oscar
>






More information about the JDev mailing list