[jdom-interest] Using XPath in Multi-Threaded Env
Rajan Gupta
rgupta99_1999 at yahoo.com
Fri Jun 6 18:49:04 PDT 2003
Jason,
I want to use XPath once constructed with different DOM Documents
essentially pre-compile & store for reuse. I believe it is possible,
but in your XPath code, you are storing the passed element to
selectSingleNode() method in a private attribute called context.
Can u please shed some light, on reusing XPath across DOM Documents
in a multi-threaded env.
Thanks in advance.
Rajan Gupta
--- Rajan Gupta <rgupta99_1999 at yahoo.com> wrote:
> Thanks for the response.
> But if were to use XPath is a threaded environment, we are assuming that
> in the future the XPath code will not be changed to start using context
> in
> some other way?
> Do u have an insight into why Jason Hunter is storing context in a
> private
> variable?
>
> Thanks again
> Rajan
> --- Laurent Bihanic <laurent.bihanic at atosorigin.com> wrote:
> >
> > Rajan Gupta wrote:
> > > Is it possible to reuse an instance of XPath across multiple
> threads
> > of
> > > execution using different instances of DOM Documents in each
> thread?
> >
> > Yes and no!
> >
> > No because, as no JDOM object is threadsafe, XPath was not designed to
> > be
> > threadsafe. For JaxenXPath to be threadsafe, context should be made a
> > thread
> > local variable.
> >
> > Yes because I do it all the time and it works. For that, you should
> not
> > rely
> > on the automatic context-based namespace prefix resolution feature.
> > Which mean
> > you should define all namespace prefix mappings using
> > XPath.addNamespace().
> >
> > Laurent
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
> http://calendar.yahoo.com
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
More information about the jdom-interest
mailing list