On Fri, 2003-12-19 at 10:02, Jeremias Maerki wrote:
> I should be thread-safe, the way it is used here. You could of course,
> cache the SAXParserFactory instance but I doubt the performance
> improvement would be measurable. getParser is probably not the best name
> if you look at it from a bean-oriented angle but it's not that it's
> called many times anyway. Do you think we should rename it?
As long as we are certain that it is being used correctly, probably
not necessary. Just jumped a bit when I saw the possibility that it
would be easily mis-used.
>
> On 19.12.2003 13:13:45 John Austin wrote:
> > I found the following snippet in the class FOFileHandler:
> >
> > ===============================================================
> > /**
> > * @see org.apache.fop.apps.InputHandler#getParser()
> > */
> > public XMLReader getParser() throws FOPException {
> > return createParser();
> > }
> > ===============================================================
> >
> > and the createParser() method
> >
> > ===============================================================
> > /**
> > * Creates <code>XMLReader</code> object using default
> > * <code>SAXParserFactory</code>
> > * @return the created <code>XMLReader</code>
> > * @throws FOPException if the parser couldn't be created or
> > configured for proper operation.
> > */
> > protected static XMLReader createParser() throws FOPException {
> > try {
> > SAXParserFactory factory = SAXParserFactory.newInstance();
> > factory.setNamespaceAware(true);
> > factory.setFeature(
> > "http://xml.org/sax/features/namespace-prefixes", true);
> > return factory.newSAXParser().getXMLReader();
> >
> > <snip/>
> >
> > ===============================================================
> >
> > Now it would seem to me that a 'getter' method should not go around
> > creating objects every time it needs to. It hust doesn't look right.
> >
> > I assume that SAXParserFactory is thread-safe.
>
>
> Jeremias Maerki
--
John Austin <[EMAIL PROTECTED]>