FileDocCategorySizeDatePackage
WSTCPFastInfosetStreamCodec.javaAPI DocExample8642Tue May 29 16:57:08 BST 2007com.sun.xml.ws.transport.tcp.encoding

WSTCPFastInfosetStreamCodec

public abstract class WSTCPFastInfosetStreamCodec extends Object implements com.sun.xml.ws.api.pipe.Codec
author
Alexey Stashok

Fields Summary
private static final int
DEFAULT_INDEXED_STRING_SIZE_LIMIT
private static final int
DEFAULT_INDEXED_STRING_MEMORY_LIMIT
private com.sun.xml.fastinfoset.stax.StAXDocumentParser
_statefulParser
private com.sun.xml.fastinfoset.stax.StAXDocumentSerializer
_serializer
private final com.sun.xml.ws.api.pipe.StreamSOAPCodec
_soapCodec
private final boolean
_retainState
protected final com.sun.xml.ws.api.pipe.ContentType
_defaultContentType
private final com.sun.xml.ws.transport.tcp.encoding.WSTCPFastInfosetStreamReaderRecyclable.RecycleAwareListener
_readerRecycleListener
Constructors Summary
WSTCPFastInfosetStreamCodec(com.sun.xml.ws.api.pipe.StreamSOAPCodec soapCodec, com.sun.xml.ws.api.SOAPVersion soapVersion, com.sun.xml.ws.transport.tcp.encoding.WSTCPFastInfosetStreamReaderRecyclable.RecycleAwareListener readerRecycleListener, boolean retainState, String mimeType)

    
    /* package */      
                   
        _soapCodec = soapCodec != null ? soapCodec : Codecs.createSOAPEnvelopeXmlCodec(soapVersion);
        _readerRecycleListener = readerRecycleListener;
        _retainState = retainState;
        _defaultContentType = new ContentTypeImpl(mimeType);
    
WSTCPFastInfosetStreamCodec(WSTCPFastInfosetStreamCodec that)

        this._soapCodec = (StreamSOAPCodec) that._soapCodec.copy();
        this._readerRecycleListener = that._readerRecycleListener;
        this._retainState = that._retainState;
        this._defaultContentType = that._defaultContentType;
    
Methods Summary
public static com.sun.xml.ws.transport.tcp.encoding.WSTCPFastInfosetStreamCodeccreate(com.sun.xml.ws.api.pipe.StreamSOAPCodec soapCodec, com.sun.xml.ws.api.SOAPVersion version, com.sun.xml.ws.transport.tcp.encoding.WSTCPFastInfosetStreamReaderRecyclable.RecycleAwareListener readerRecycleListener, boolean retainState)
Creates a new {@link FastInfosetStreamSOAPCodec} instance.

param
version the SOAP version of the codec.
return
a new {@link WSTCPFastInfosetStreamCodec} instance.

        if(version==null)
            // this decoder is for SOAP, not for XML/HTTP
            throw new IllegalArgumentException();
        switch(version) {
            case SOAP_11:
                return new WSTCPFastInfosetStreamSOAP11Codec(soapCodec, readerRecycleListener, retainState);
            case SOAP_12:
                return new WSTCPFastInfosetStreamSOAP12Codec(soapCodec, readerRecycleListener, retainState);
            default:
                throw new AssertionError();
        }
    
protected abstract com.sun.xml.ws.message.stream.StreamHeadercreateHeader(javax.xml.stream.XMLStreamReader reader, com.sun.xml.stream.buffer.XMLStreamBuffer mark)

public voiddecode(java.io.InputStream in, java.lang.String contentType, com.sun.xml.ws.api.message.Packet response)

        response.setMessage(
                _soapCodec.decode(getXMLStreamReader(in)));
    
public voiddecode(java.nio.channels.ReadableByteChannel in, java.lang.String contentType, com.sun.xml.ws.api.message.Packet response)

        throw new UnsupportedOperationException();
    
public com.sun.xml.ws.api.pipe.ContentTypeencode(com.sun.xml.ws.api.message.Packet packet, java.io.OutputStream out)

        if (packet.getMessage() != null) {
            final XMLStreamWriter writer = getXMLStreamWriter(out);
            try {
                packet.getMessage().writeTo(writer);
                writer.flush();
            } catch (XMLStreamException e) {
                throw new WebServiceException(e);
            }
        }
        return getContentType(packet.soapAction);
    
public com.sun.xml.ws.api.pipe.ContentTypeencode(com.sun.xml.ws.api.message.Packet packet, java.nio.channels.WritableByteChannel buffer)

        //TODO: not yet implemented
        throw new UnsupportedOperationException();
    
protected abstract com.sun.xml.ws.api.pipe.ContentTypegetContentType(java.lang.String soapAction)

public java.lang.StringgetMimeType()

        return _defaultContentType.getContentType();
    
public com.sun.xml.ws.api.pipe.ContentTypegetStaticContentType(com.sun.xml.ws.api.message.Packet packet)

        return getContentType(packet.soapAction);
    
private javax.xml.stream.XMLStreamReadergetXMLStreamReader(java.io.InputStream in)

        if (_statefulParser != null) {
            _statefulParser.setInputStream(in);
            return _statefulParser;
        } else {
            StAXDocumentParser parser = new WSTCPFastInfosetStreamReaderRecyclable(in, _readerRecycleListener);
            parser.setStringInterning(true);
            if (_retainState) {
                ParserVocabulary vocabulary = new ParserVocabulary();
                parser.setVocabulary(vocabulary);
            }
            _statefulParser = parser;
            return _statefulParser;
        }
    
private javax.xml.stream.XMLStreamWritergetXMLStreamWriter(java.io.OutputStream out)

        if (_serializer != null) {
            _serializer.setOutputStream(out);
            return _serializer;
        } else {
            StAXDocumentSerializer serializer = new StAXDocumentSerializer(out);
            if (_retainState) {
                SerializerVocabulary vocabulary = new SerializerVocabulary();
                serializer.setVocabulary(vocabulary);
                serializer.setAttributeValueSizeLimit(DEFAULT_INDEXED_STRING_SIZE_LIMIT);
                serializer.setCharacterContentChunkSizeLimit(DEFAULT_INDEXED_STRING_SIZE_LIMIT);
                serializer.setAttributeValueMapMemoryLimit(DEFAULT_INDEXED_STRING_MEMORY_LIMIT);
                serializer.setCharacterContentChunkMapMemoryLimit(DEFAULT_INDEXED_STRING_MEMORY_LIMIT);
            }
            _serializer = serializer;
            return serializer;
        }