[jdom-interest] Piping an XML Doc between threads, How?

Ray Lukas rlukas at cadence.com
Fri Dec 7 07:51:37 PST 2001

Sorry to bother you... I was wondering is anyone could help me through some
confusion I am having. I am just starting to really use JDom and so far so
good. It is a great interface to handling XML. I can not wait to play with
the XSL stuff. But to the point...

I am building a system with multiple threads, each thread handles a
different layer of processing an XML document. So I need to pipe this XML
document from one thread to another. This is how I normally do my thread
communication for simple things like Strings and such.

    private boolean pipeOutToGeneratorThread(List processedData) throws
Exception {
        // creating an output pipe for the thread to write to
        PipedWriter pipeOut = new PipedWriter();
        PrintWriter out     = new PrintWriter(pipeOut);
        // this is what the next thread is going to read from
        PipedReader pipeIn  = new PipedReader(pipeOut);

        Thread generatorThread  = new Thread(new GeneratorThread(pipeIn));
        pipeOutData(processedData, out);   // this basically does a
        return true;

So looking through the JDom API I found the XMLOutputer and, of course, the
makeWriter method which returns me a Writer.. But I need a PipedWriter and
there does not seem to be a way to get a PipedWriter ... I guess that I
could just do a PipedOutputStream but that doesn't help either... I think
that I am making this more complicated than it has to be. Can someone help
me with a  clear simple example of piping a JDom document between threads.
Surly I am not the first to do this and perhaps someone could post a chunk
of code for me, and probably others as well....

Thanks ray
Ray Lukas
RLukas at Cadence.Com
(work) 978.262.6297
(fax) 978.262.6777

More information about the jdom-interest mailing list