dev@jax-ws.java.net

Re: XMLStreamReader recycling <was> [Fwd: CVS update [mr-21]: /jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/message/stream/]

From: Venu <K.Venugopal_at_Sun.COM>
Date: Thu, 11 Jan 2007 15:19:45 +0530

Paul Sandoz wrote:
> Hi,
>
> This recycling is related to the same issue for the FI StAX parsers.
>
> I have not looked deeply at the code but it looks like the right place
> to support the recycling of XML *and* FI XMLStreamReader instances.
>
> I am wondering if it is possible to also recycle stream buffers i.e.
> when the message is no longer used.
when would one know it is time to recycle stream buffers.
In cases where message is converted to JAXB/DOM before handing it over
to user application, it might be easier for JAXWS Message to release
the buffers.

Regards,
Venu

>
> Paul.
>
>
> ------------------------------------------------------------------------
>
> Subject:
> CVS update [mr-21]:
> /jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/message/stream/
> From:
> kohsuke_at_dev.java.net
> Date:
> Thu, 11 Jan 2007 02:17:43 +0000
> To:
> cvs_at_jax-ws-sources.dev.java.net
>
> To:
> cvs_at_jax-ws-sources.dev.java.net
>
>
> Tag: mr-21
> User: kohsuke
> Date: 2007/01/10 18:17:43
>
> Modified:
> jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/message/stream/StreamMessage.java
>
> Log:
> adding recycle invocation.
>
> File Changes:
>
> Directory: /jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/message/stream/
> =========================================================================
>
> File [changed]: StreamMessage.java
> Url: https://jax-ws-sources.dev.java.net/source/browse/jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/message/stream/StreamMessage.java?r1=1.1.2.7.2.11&r2=1.1.2.7.2.12
> Delta lines: +13 -3
> --------------------
> --- StreamMessage.java 10 Jan 2007 03:14:51 -0000 1.1.2.7.2.11
> +++ StreamMessage.java 11 Jan 2007 02:17:40 -0000 1.1.2.7.2.12
> @@ -34,6 +34,7 @@
> import com.sun.xml.ws.encoding.TagInfoset;
> import com.sun.xml.ws.message.AbstractMessageImpl;
> import com.sun.xml.ws.message.AttachmentUnmarshallerImpl;
> +import com.sun.xml.ws.streaming.XMLStreamReaderFactory;
> import com.sun.xml.ws.streaming.XMLStreamReaderUtil;
> import com.sun.xml.ws.util.xml.DummyLocation;
> import com.sun.xml.ws.util.xml.StAXSource;
> @@ -46,9 +47,13 @@
>
> import javax.xml.bind.JAXBException;
> import javax.xml.bind.Unmarshaller;
> -import javax.xml.stream.*;
> +import javax.xml.stream.Location;
> +import javax.xml.stream.XMLStreamConstants;
> import static javax.xml.stream.XMLStreamConstants.START_DOCUMENT;
> import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
> +import javax.xml.stream.XMLStreamException;
> +import javax.xml.stream.XMLStreamReader;
> +import javax.xml.stream.XMLStreamWriter;
> import javax.xml.transform.Source;
> import javax.xml.ws.WebServiceException;
>
> @@ -198,6 +203,7 @@
> return unmarshaller.unmarshal(reader);
> } finally{
> unmarshaller.setAttachmentUnmarshaller(null);
> + XMLStreamReaderFactory.recycle(reader);
> }
> }
>
> @@ -205,8 +211,10 @@
> if(!hasPayload())
> return null;
> assert unconsumed();
> - return bridge.unmarshal(reader,
> - hasAttachments()? new AttachmentUnmarshallerImpl(getAttachments()) : null );
> + T r = bridge.unmarshal(reader,
> + hasAttachments() ? new AttachmentUnmarshallerImpl(getAttachments()) : null);
> + XMLStreamReaderFactory.recycle(reader);
> + return r;
> }
>
> public XMLStreamReader readPayload() {
> @@ -241,6 +249,7 @@
> conv.bridge(reader,writer);
> }
> reader.close();
> + XMLStreamReaderFactory.recycle(reader);
> }
>
> public void writeTo(XMLStreamWriter sw) throws XMLStreamException{
> @@ -303,6 +312,7 @@
> conv.bridge();
> }
> reader.close();
> + XMLStreamReaderFactory.recycle(reader);
> } catch (XMLStreamException e) {
> Location loc = e.getLocation();
> if(loc==null) loc = DummyLocation.INSTANCE;
>
>
>
>
> ---------------------------------------------------------------------
> 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 unsubscribe, e-mail: dev-unsubscribe_at_jax-ws.dev.java.net
> For additional commands, e-mail: dev-help_at_jax-ws.dev.java.net
>