com.sun.xml.ws.api.streaming
Class XMLStreamWriterFactory

java.lang.Object
  extended by com.sun.xml.ws.api.streaming.XMLStreamWriterFactory
Direct Known Subclasses:
XMLStreamWriterFactory.Default, XMLStreamWriterFactory.NoLock, XMLStreamWriterFactory.Zephyr

public abstract class XMLStreamWriterFactory
extends java.lang.Object

Factory for XMLStreamWriter.

This wraps XMLOutputFactory and allows us to reuse XMLStreamWriter instances when appropriate.


Nested Class Summary
static class XMLStreamWriterFactory.Default
          Default XMLStreamWriterFactory implementation that can work with any XMLOutputFactory.
static class XMLStreamWriterFactory.NoLock
          For XMLOutputFactory is thread safe.
static interface XMLStreamWriterFactory.RecycleAware
          Interface that can be implemented by XMLStreamWriter to be notified when it's recycled.
static class XMLStreamWriterFactory.Zephyr
          XMLStreamWriterFactory implementation for Sun's StaX implementation.
 
Constructor Summary
XMLStreamWriterFactory()
           
 
Method Summary
static javax.xml.stream.XMLStreamWriter create(java.io.OutputStream out)
          Short-cut for create(OutputStream, String) with UTF-8.
static javax.xml.stream.XMLStreamWriter create(java.io.OutputStream out, java.lang.String encoding)
           
static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(java.io.OutputStream out)
          Deprecated. Use create(OutputStream)
static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(java.io.OutputStream out, java.lang.String encoding)
          Deprecated. Use create(OutputStream, String)
static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(java.io.OutputStream out, java.lang.String encoding, boolean declare)
          Deprecated. Use create(OutputStream, String). The boolean flag was unused anyway.
abstract  javax.xml.stream.XMLStreamWriter doCreate(java.io.OutputStream out)
          See create(OutputStream) for the contract.
abstract  javax.xml.stream.XMLStreamWriter doCreate(java.io.OutputStream out, java.lang.String encoding)
          See create(OutputStream,String) for the contract.
abstract  void doRecycle(javax.xml.stream.XMLStreamWriter r)
          See recycle(XMLStreamWriter) for the contract.
static XMLStreamWriterFactory get()
          Gets the singleton instance.
static void recycle(javax.xml.stream.XMLStreamWriter r)
          Should be invoked when the code finished using an XMLStreamWriter.
static void set(XMLStreamWriterFactory f)
          Overrides the singleton XMLStreamWriterFactory instance that the JAX-WS RI uses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLStreamWriterFactory

public XMLStreamWriterFactory()
Method Detail

doCreate

public abstract javax.xml.stream.XMLStreamWriter doCreate(java.io.OutputStream out)
See create(OutputStream) for the contract. This method may be invoked concurrently.


doCreate

public abstract javax.xml.stream.XMLStreamWriter doCreate(java.io.OutputStream out,
                                                          java.lang.String encoding)
See create(OutputStream,String) for the contract. This method may be invoked concurrently.


doRecycle

public abstract void doRecycle(javax.xml.stream.XMLStreamWriter r)
See recycle(XMLStreamWriter) for the contract. This method may be invoked concurrently.


recycle

public static void recycle(javax.xml.stream.XMLStreamWriter r)
Should be invoked when the code finished using an XMLStreamWriter.

If the recycled instance implements XMLStreamWriterFactory.RecycleAware, XMLStreamWriterFactory.RecycleAware.onRecycled() will be invoked to let the instance know that it's being recycled.

It is not a hard requirement to call this method on every XMLStreamReader instance. Not doing so just reduces the performance by throwing away possibly reusable instances. So the caller should always consider the effort it takes to recycle vs the possible performance gain by doing so.

This method may be invked by multiple threads concurrently.

Parameters:
r - The XMLStreamReader instance that the caller finished using. This could be any XMLStreamReader implementation, not just the ones that were created from this factory. So the implementation of this class needs to be aware of that.

get

@NotNull
public static XMLStreamWriterFactory get()
Gets the singleton instance.


set

public static void set(@NotNull
                       XMLStreamWriterFactory f)
Overrides the singleton XMLStreamWriterFactory instance that the JAX-WS RI uses.

Parameters:
f - must not be null.

create

public static javax.xml.stream.XMLStreamWriter create(java.io.OutputStream out)
Short-cut for create(OutputStream, String) with UTF-8.


create

public static javax.xml.stream.XMLStreamWriter create(java.io.OutputStream out,
                                                      java.lang.String encoding)

createXMLStreamWriter

public static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(java.io.OutputStream out)
Deprecated. Use create(OutputStream)


createXMLStreamWriter

public static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(java.io.OutputStream out,
                                                                     java.lang.String encoding)
Deprecated. Use create(OutputStream, String)


createXMLStreamWriter

public static javax.xml.stream.XMLStreamWriter createXMLStreamWriter(java.io.OutputStream out,
                                                                     java.lang.String encoding,
                                                                     boolean declare)
Deprecated. Use create(OutputStream, String). The boolean flag was unused anyway.



Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.