dev@jax-ws.java.net

HTTP-based codecs checking for empty messages <was> Re: CVS update [mr-21]: /jax-ws-sources/jaxws-ri/rt-fi/src/com/sun/xml/ws/encoding/fastinfoset/

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 08 Jan 2007 16:41:28 +0100

Hi,

If transport is able to inform the packet that content is present or not
then the binding could ignore using the codec then we would not need to
do this type of 'hack'.

Alexey, you may also want to look at reusing parsers instances for
decoding as the FastInfosetSource will create a new SAXDocmentParser
instance.

Paul.

oleksiys_at_dev.java.net wrote:
> Tag: mr-21
> User: oleksiys
> Date: 2007/01/08 06:06:28
>
> Modified:
> jax-ws-sources/jaxws-ri/rt-fi/src/com/sun/xml/ws/encoding/fastinfoset/FastInfosetCodec.java
>
> Log:
> Fix for issue #184
> Check for empty payload added
>
> File Changes:
>
> Directory: /jax-ws-sources/jaxws-ri/rt-fi/src/com/sun/xml/ws/encoding/fastinfoset/
> ==================================================================================
>
> File [changed]: FastInfosetCodec.java
> Url: https://jax-ws-sources.dev.java.net/source/browse/jax-ws-sources/jaxws-ri/rt-fi/src/com/sun/xml/ws/encoding/fastinfoset/FastInfosetCodec.java?r1=1.1.4.5&r2=1.1.4.6
> Delta lines: +58 -22
> ---------------------
> --- FastInfosetCodec.java 18 Dec 2006 15:00:24 -0000 1.1.4.5
> +++ FastInfosetCodec.java 8 Jan 2007 14:06:25 -0000 1.1.4.6
> @@ -32,6 +32,7 @@
> import com.sun.xml.ws.api.pipe.ContentType;
> import com.sun.xml.ws.api.message.Packet;
> import com.sun.xml.ws.encoding.ContentTypeImpl;
> +import java.io.BufferedInputStream;
>
> import javax.xml.stream.XMLStreamException;
> import javax.xml.stream.XMLStreamWriter;
> @@ -103,8 +104,17 @@
> }
>
> public void decode(InputStream in, String contentType, Packet packet) throws IOException {
> - Message message = Messages.createUsingPayload(new FastInfosetSource(in),
> + /* Implements similar logic as the XMLMessage.create(String, InputStream).
> + * But it's faster, as we know the InputStream has FastInfoset content*/
> + Message message = null;
> + in = hasSomeData(in);
> + if (in != null) {
> + message = Messages.createUsingPayload(new FastInfosetSource(in),
> SOAPVersion.SOAP_11);
> + } else {
> + message = Messages.createEmpty(SOAPVersion.SOAP_11);
> + }
> +
> packet.setMessage(message);
> }
>
> @@ -212,5 +222,31 @@
> parser.setVocabulary(vocabulary);
> }
> return parser;
> + }
> +
> + /**
> + * Method is copied from com.sun.xml.ws.encoding.xml.XMLMessage
> + * @TODO method should be public in some util package?
> + *
> + * Finds if the stream has some content or not
> + *
> + * @return null if there is no data
> + * else stream to be used
> + */
> + private static InputStream hasSomeData(InputStream in) throws IOException {
> + if (in != null) {
> + if (in.available() < 1) {
> + if (!in.markSupported()) {
> + in = new BufferedInputStream(in);
> + }
> + in.mark(1);
> + if (in.read() != -1) {
> + in.reset();
> + } else {
> + in = null; // No data
> + }
> + }
> + }
> + return in;
> }
> }
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cvs-unsubscribe_at_jax-ws-sources.dev.java.net
> For additional commands, e-mail: cvs-help_at_jax-ws-sources.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109