You can reuse SAXReader instances as many times as you like; the only issue is you cannot use a SAXReader concurrently in multiple threads. So creating an object pool of SAXReader objects makes a lot of sense.
If you're looking for an object pool implementation, this one at Jakarta looks reasonable... http://jakarta.apache.org/commons/pool/index.html James ----- Original Message ----- From: "K.Gillies" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, May 03, 2002 11:48 PM Subject: [dom4j-user] Reuse of SAXReader? > Hi, > Since I need to parse a lot of documents of a few different types > (instances I guess), I'd like to create one or more XML parsers (as > SAXReader instances) to reuse. I'd like to treat these parsers as > resources like database connections, for instance. > > So my question is, is it ok to reuse a SAXReader or do I need to > create a new one each time I need to parse a document. I know that the > XML parser is not reentrant. I've looked at the source for SAXReader, > and I see that quite a bit is done when read is called but a new > instance of the parser is not created if it already exists > (getXMLReader) so this suggests to me that someone expected reuse of > SAXReader. Please comment on the use of SAXReaders as pooled objects. > If you think this is a total waste of time, I'd be interested in hearing > that too. I've not done any benchmarking that suggests that this is > really where I'm spending a lot of time, but I do think parsers are > pretty heavyweight objects to create every time I parse a document. > > The following is from a newcomer to dom4j so take that into > consideration too! If you don't mind, please cc your email to > [EMAIL PROTECTED], I'm not (yet) a list member. I'm just testing dom4j. > > Thanks, > K.Gillies > > > _______________________________________________________________ > > Have big pipes? SourceForge.net is looking for download mirrors. We supply > the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] > _______________________________________________ > dom4j-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/dom4j-user _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________________________ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user
