<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [JDEV] Question on using NIO with SAX</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Thanks for the info. I will look into it and see if I can find something useful.</FONT>
</P>
<P><FONT SIZE=2>Oscar</FONT>
</P>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Joe Hildebrand [<A HREF="mailto:jhildebrand@jabber.com">mailto:jhildebrand@jabber.com</A>]</FONT>
<BR><FONT SIZE=2>Sent: Friday, March 22, 2002 9:26 AM</FONT>
<BR><FONT SIZE=2>To: jdev@jabber.org</FONT>
<BR><FONT SIZE=2>Subject: Re: [JDEV] Question on using NIO with SAX</FONT>
</P>
<BR>
<BR>
<P><FONT SIZE=2>I did a JNI wrapper around xpat for marbles, as a stop-gap.</FONT>
</P>
<P><FONT SIZE=2><A HREF="http://marbles.sourceforge.net/" TARGET="_blank">http://marbles.sourceforge.net/</A></FONT>
</P>
<P><FONT SIZE=2>Haven't worked on it in a while, but it should still be there.</FONT>
</P>
<BR>
<BR>
<P><FONT SIZE=2>"Chan, Oscar" <OChan@pogo.com> writes:</FONT>
</P>
<P><FONT SIZE=2>> Thanks. I guess I will have to live with this until the SAX API provide</FONT>
<BR><FONT SIZE=2>> API for this push-model parser. </FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> I looked at the Xerces-J parser's parseSome() method, but it is only for</FONT>
<BR><FONT SIZE=2>> parsing the first line of XML document to get the encoding in XML</FONT>
<BR><FONT SIZE=2>> Declaration, so it does not work in the way that I needed.</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> Thanks again, </FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> Oscar </FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> -----Original Message----- </FONT>
<BR><FONT SIZE=2>> From: David Waite [ <A HREF="mailto:mass@akuma.org">mailto:mass@akuma.org</A> <<A HREF="mailto:mass@akuma.org">mailto:mass@akuma.org</A>> ] </FONT>
<BR><FONT SIZE=2>> Sent: Thursday, March 21, 2002 5:16 PM </FONT>
<BR><FONT SIZE=2>> To: jdev@jabber.org </FONT>
<BR><FONT SIZE=2>> Subject: Re: [JDEV] Question on using NIO with SAX </FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> This is an issue with the SAX Api (which understandably, we can't </FONT>
<BR><FONT SIZE=2>> change). What you want is a push-model parser (like SAX) which takes a </FONT>
<BR><FONT SIZE=2>> block of bytes/characters and calls events on the DocumentHandler (on </FONT>
<BR><FONT SIZE=2>> that thread) until that block of data has been processed, then returns </FONT>
<BR><FONT SIZE=2>> or saves the remainder until the next time it is passed. SAX does not </FONT>
<BR><FONT SIZE=2>> define this, and anything which does this at least is extending SAX. </FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> I believe Xerces-J at least defines a parseSome method on its XmlParser </FONT>
<BR><FONT SIZE=2>> method, but I don't know if this does what you want. </FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> -David Waite </FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> Chan, Oscar wrote: </FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>>> Hi all, </FONT>
<BR><FONT SIZE=2>>> </FONT>
<BR><FONT SIZE=2>>> I am new here. I am now developing a message server based on the </FONT>
<BR><FONT SIZE=2>>> subset of Jabber protocol. I am building using Java, and SAX parser in</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>>> javax.xml.parsers package. My problem is that I am trying to code </FONT>
<BR><FONT SIZE=2>>> the server so that it can use NIO (new i/o) package once java 1.4 is </FONT>
<BR><FONT SIZE=2>>> stable enough to use. By using NIO, it eliminates the problem of </FONT>
<BR><FONT SIZE=2>>> having a thread per socket because it multiplexes the input and store </FONT>
<BR><FONT SIZE=2>>> the data in a buffer instead of blocking the call and waiting until </FONT>
<BR><FONT SIZE=2>>> data is available. Usually, the server machine will slow down when </FONT>
<BR><FONT SIZE=2>>> the number of thread reach about 1000. Therefore, NIO will increase </FONT>
<BR><FONT SIZE=2>>> the number of connection that we can have. </FONT>
<BR><FONT SIZE=2>>> </FONT>
<BR><FONT SIZE=2>>> Since parse() method in java.xml.parsers.SAXParser is using a blocking</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>>> I/O and, hence, it increase the number of threads. Does anyone know </FONT>
<BR><FONT SIZE=2>>> any workaround for it, or any future support for SAX using NIO? </FONT>
<BR><FONT SIZE=2>>> </FONT>
<BR><FONT SIZE=2>>> Thanks </FONT>
<BR><FONT SIZE=2>>> </FONT>
<BR><FONT SIZE=2>>> Oscar </FONT>
<BR><FONT SIZE=2>>> </FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> _______________________________________________ </FONT>
<BR><FONT SIZE=2>> jdev mailing list </FONT>
<BR><FONT SIZE=2>> jdev@jabber.org </FONT>
<BR><FONT SIZE=2>> <A HREF="http://mailman.jabber.org/listinfo/jdev" TARGET="_blank">http://mailman.jabber.org/listinfo/jdev</A></FONT>
<BR><FONT SIZE=2>> <<A HREF="http://mailman.jabber.org/listinfo/jdev" TARGET="_blank">http://mailman.jabber.org/listinfo/jdev</A>> </FONT>
<BR><FONT SIZE=2>></FONT>
</P>
<P><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>Joe Hildebrand</FONT>
<BR><FONT SIZE=2>Chief Architect</FONT>
<BR><FONT SIZE=2>Jabber, Inc.</FONT>
<BR><FONT SIZE=2><A HREF="http://www.jabber.com/" TARGET="_blank">http://www.jabber.com/</A></FONT>
</P>
<P><FONT SIZE=2>_______________________________________________</FONT>
<BR><FONT SIZE=2>jdev mailing list</FONT>
<BR><FONT SIZE=2>jdev@jabber.org</FONT>
<BR><FONT SIZE=2><A HREF="http://mailman.jabber.org/listinfo/jdev" TARGET="_blank">http://mailman.jabber.org/listinfo/jdev</A></FONT>
</P>
</BODY>
</HTML>