users@jaxb.java.net

RE: Re: Unmarshalling via InputStream

From: Malachi de Aelfweald <malachid_at_temporal-wave.com>
Date: Fri, 22 Aug 2003 10:45:15 -0700

A currently distributed app of ours successfully does this:

DOMParser parser = new DOMParser();
parser.parse(new InputStreamReader(connection.getInputStream());,
utf8));
return (new org.jdom.input.DOMBuilder()).build(parser.getDocument());

and then sends a response back on the same socket.

Malachi

-----Original Message-----
From: Ryan Shoemaker - JavaSoft East [mailto:Ryan.Shoemaker_at_Sun.COM]
Sent: Friday, August 22, 2003 10:01 AM
To: users_at_jaxb.dev.java.net

Malachi de Aelfweald wrote:
> Ok, so here's the deal.... I implemented a MultiplexedInputStream
(and
> MultiplexedOutputStream). Calling unmarshal indirectly closes the
> stream BECAUSE XmlReader$Utf8Reader closes the stream once it is done
> reading. I am looking at overriding the close method, but..... there
> REALLY needs to be a better way to read/write JAXB from/to a SOCKET.
>

Understood, but it isn't JAXB's fault that the underlying parser is
closing the stream. In your case, we're simply using:

        org.xml.sax.XMLReader.parse( InputStream )

to unmarshal from your wrapped socket.

The javadoc says: "This method is synchronous: it will not return until
parsing has ended. If a client application wants to terminate parsing
early, it should throw an exception." The client owns the InputStream,
not the parser, so I've surprised that the parser would close it.

Just for kicks, can you try using Xerces to see how it behaves?

--Ryan


>
> reading taskman from the socket
> com.temporalwave.io.MultiplexedInputStream is closing!
> ** TRACE START
> com.temporalwave.util.RuntimeUtil(printStackTrace): line #-1
> com.temporalwave.util.RuntimeUtil(printStackTrace): line #-1
> com.temporalwave.io.MultiplexedInputStream(close): line #-1
> java.io.PushbackInputStream(close): line #303
> org.apache.crimson.parser.XmlReader$BaseReader(close): line #595
> org.apache.crimson.parser.XmlReader$Utf8Reader(read): line #647
> org.apache.crimson.parser.XmlReader(read): line #487
> org.apache.crimson.parser.InputEntity(fillbuf): line #1068
> org.apache.crimson.parser.InputEntity(isXmlDeclOrTextDeclPrefix): line
> #914
> org.apache.crimson.parser.Parser2(maybeXmlDecl): line #1150
> org.apache.crimson.parser.Parser2(parseInternal): line #620
> org.apache.crimson.parser.Parser2(parse): line #333
> org.apache.crimson.parser.XMLReaderImpl(parse): line #448
>
com.temporalwave.spec.taskman.impl.runtime.UnmarshallerImpl(unmarshal):
> line #-1
> javax.xml.bind.helpers.AbstractUnmarshallerImpl(unmarshal): line #131
> javax.xml.bind.helpers.AbstractUnmarshallerImpl(unmarshal): line #178
> com.temporalwave.util.JAXBUtil(read): line #-1
> com.temporalwave.taskman.server.RequestHandler(run): line #-1
> ** TRACE END


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net