feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,273 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.encoding.fastinfoset;
|
||||
|
||||
import com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerializer;
|
||||
import com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser;
|
||||
import com.sun.xml.internal.fastinfoset.vocab.ParserVocabulary;
|
||||
import com.sun.xml.internal.fastinfoset.vocab.SerializerVocabulary;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.message.Message;
|
||||
import com.sun.xml.internal.ws.api.message.Messages;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.pipe.ContentType;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.encoding.ContentTypeImpl;
|
||||
import java.io.BufferedInputStream;
|
||||
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetSource;
|
||||
|
||||
/**
|
||||
* A codec for encoding/decoding XML infosets to/from fast
|
||||
* infoset documents.
|
||||
*
|
||||
* @author Paul Sandoz
|
||||
*/
|
||||
public class FastInfosetCodec implements Codec {
|
||||
private static final int DEFAULT_INDEXED_STRING_SIZE_LIMIT = 32;
|
||||
private static final int DEFAULT_INDEXED_STRING_MEMORY_LIMIT = 4 * 1024 * 1024; //4M limit
|
||||
|
||||
private StAXDocumentParser _parser;
|
||||
|
||||
private StAXDocumentSerializer _serializer;
|
||||
|
||||
private final boolean _retainState;
|
||||
|
||||
private final ContentType _contentType;
|
||||
|
||||
/* package */ FastInfosetCodec(boolean retainState) {
|
||||
_retainState = retainState;
|
||||
_contentType = (retainState) ? new ContentTypeImpl(FastInfosetMIMETypes.STATEFUL_INFOSET) :
|
||||
new ContentTypeImpl(FastInfosetMIMETypes.INFOSET);
|
||||
}
|
||||
|
||||
public String getMimeType() {
|
||||
return _contentType.getContentType();
|
||||
}
|
||||
|
||||
public Codec copy() {
|
||||
return new FastInfosetCodec(_retainState);
|
||||
}
|
||||
|
||||
public ContentType getStaticContentType(Packet packet) {
|
||||
return _contentType;
|
||||
}
|
||||
|
||||
public ContentType encode(Packet packet, OutputStream out) {
|
||||
Message message = packet.getMessage();
|
||||
if (message != null && message.hasPayload()) {
|
||||
final XMLStreamWriter writer = getXMLStreamWriter(out);
|
||||
try {
|
||||
writer.writeStartDocument();
|
||||
packet.getMessage().writePayloadTo(writer);
|
||||
writer.writeEndDocument();
|
||||
writer.flush();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return _contentType;
|
||||
}
|
||||
|
||||
public ContentType encode(Packet packet, WritableByteChannel buffer) {
|
||||
//TODO: not yet implemented
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void decode(InputStream in, String contentType, Packet packet) throws IOException {
|
||||
/* Implements similar logic as the XMLMessage.create(String, InputStream).
|
||||
* But it's faster, as we know the InputStream has FastInfoset content*/
|
||||
Message message;
|
||||
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);
|
||||
}
|
||||
|
||||
public void decode(ReadableByteChannel in, String contentType, Packet response) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private XMLStreamWriter getXMLStreamWriter(OutputStream out) {
|
||||
if (_serializer != null) {
|
||||
_serializer.setOutputStream(out);
|
||||
return _serializer;
|
||||
} else {
|
||||
return _serializer = createNewStreamWriter(out, _retainState);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link FastInfosetCodec} instance.
|
||||
*
|
||||
* @return a new {@link FastInfosetCodec} instance.
|
||||
*/
|
||||
public static FastInfosetCodec create() {
|
||||
return create(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link FastInfosetCodec} instance.
|
||||
*
|
||||
* @param retainState if true the Codec should retain the state of
|
||||
* vocabulary tables for multiple encode/decode invocations.
|
||||
* @return a new {@link FastInfosetCodec} instance.
|
||||
*/
|
||||
public static FastInfosetCodec create(boolean retainState) {
|
||||
return new FastInfosetCodec(retainState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new (@link StAXDocumentSerializer} instance.
|
||||
*
|
||||
* @param in the OutputStream to serialize to.
|
||||
* @param retainState if true the serializer should retain the state of
|
||||
* vocabulary tables for multiple serializations.
|
||||
* @return a new {@link StAXDocumentSerializer} instance.
|
||||
*/
|
||||
/* package */ static StAXDocumentSerializer createNewStreamWriter(OutputStream out, boolean retainState) {
|
||||
return createNewStreamWriter(out, retainState, DEFAULT_INDEXED_STRING_SIZE_LIMIT, DEFAULT_INDEXED_STRING_MEMORY_LIMIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new (@link StAXDocumentSerializer} instance.
|
||||
*
|
||||
* @param in the OutputStream to serialize to.
|
||||
* @param retainState if true the serializer should retain the state of
|
||||
* vocabulary tables for multiple serializations.
|
||||
* @return a new {@link StAXDocumentSerializer} instance.
|
||||
*/
|
||||
/* package */ static StAXDocumentSerializer createNewStreamWriter(OutputStream out,
|
||||
boolean retainState, int indexedStringSizeLimit, int stringsMemoryLimit) {
|
||||
StAXDocumentSerializer serializer = new StAXDocumentSerializer(out);
|
||||
if (retainState) {
|
||||
/**
|
||||
* Create a serializer vocabulary external to the serializer.
|
||||
* This will ensure that the vocabulary will never be cleared
|
||||
* for each serialization and will be retained (and will grow)
|
||||
* for each serialization
|
||||
*/
|
||||
SerializerVocabulary vocabulary = new SerializerVocabulary();
|
||||
serializer.setVocabulary(vocabulary);
|
||||
serializer.setMinAttributeValueSize(0);
|
||||
serializer.setMaxAttributeValueSize(indexedStringSizeLimit);
|
||||
serializer.setMinCharacterContentChunkSize(0);
|
||||
serializer.setMaxCharacterContentChunkSize(indexedStringSizeLimit);
|
||||
serializer.setAttributeValueMapMemoryLimit(stringsMemoryLimit);
|
||||
serializer.setCharacterContentChunkMapMemoryLimit(stringsMemoryLimit);
|
||||
}
|
||||
return serializer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new (@link StAXDocumentParser} instance.
|
||||
*
|
||||
* @param in the InputStream to parse from.
|
||||
* @param retainState if true the parser should retain the state of
|
||||
* vocabulary tables for multiple parses.
|
||||
* @return a new {@link StAXDocumentParser} instance.
|
||||
*/
|
||||
/* package */ static StAXDocumentParser createNewStreamReader(InputStream in, boolean retainState) {
|
||||
StAXDocumentParser parser = new StAXDocumentParser(in);
|
||||
parser.setStringInterning(true);
|
||||
if (retainState) {
|
||||
/**
|
||||
* Create a parser vocabulary external to the parser.
|
||||
* This will ensure that the vocabulary will never be cleared
|
||||
* for each parse and will be retained (and will grow)
|
||||
* for each parse.
|
||||
*/
|
||||
ParserVocabulary vocabulary = new ParserVocabulary();
|
||||
parser.setVocabulary(vocabulary);
|
||||
}
|
||||
return parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new (@link StAXDocumentParser} recyclable instance.
|
||||
*
|
||||
* @param in the InputStream to parse from.
|
||||
* @param retainState if true the parser should retain the state of
|
||||
* vocabulary tables for multiple parses.
|
||||
* @return a new recyclable {@link StAXDocumentParser} instance.
|
||||
*/
|
||||
/* package */ static StAXDocumentParser createNewStreamReaderRecyclable(InputStream in, boolean retainState) {
|
||||
StAXDocumentParser parser = new FastInfosetStreamReaderRecyclable(in);
|
||||
parser.setStringInterning(true);
|
||||
parser.setForceStreamClose(true);
|
||||
if (retainState) {
|
||||
/**
|
||||
* Create a parser vocabulary external to the parser.
|
||||
* This will ensure that the vocabulary will never be cleared
|
||||
* for each parse and will be retained (and will grow)
|
||||
* for each parse.
|
||||
*/
|
||||
ParserVocabulary vocabulary = new ParserVocabulary();
|
||||
parser.setVocabulary(vocabulary);
|
||||
}
|
||||
return parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method is copied from com.sun.xml.internal.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.encoding.fastinfoset;
|
||||
|
||||
/**
|
||||
* MIME types for Infosets encoded as fast infoset documents.
|
||||
*
|
||||
* @author Paul.Sandoz@Sun.Com
|
||||
*/
|
||||
public final class FastInfosetMIMETypes {
|
||||
/**
|
||||
* MIME type for a generic Infoset encoded as a fast infoset document.
|
||||
*/
|
||||
static public final String INFOSET = "application/fastinfoset";
|
||||
/**
|
||||
* MIME type for a SOAP 1.1 Infoset encoded as a fast infoset document.
|
||||
*/
|
||||
static public final String SOAP_11 = "application/fastinfoset";
|
||||
/**
|
||||
* MIME type for a SOAP 1.2 Infoset encoded as a fast infoset document.
|
||||
*/
|
||||
static public final String SOAP_12 = "application/soap+fastinfoset";
|
||||
|
||||
/**
|
||||
* MIME type for a generic Infoset encoded as a stateful fast infoset document.
|
||||
*/
|
||||
static public final String STATEFUL_INFOSET = "application/vnd.sun.stateful.fastinfoset";
|
||||
/**
|
||||
* MIME type for a SOAP 1.1 Infoset encoded as a stateful fast infoset document.
|
||||
*/
|
||||
static public final String STATEFUL_SOAP_11 = "application/vnd.sun.stateful.fastinfoset";
|
||||
/**
|
||||
* MIME type for a SOAP 1.2 Infoset encoded as a stateful fast infoset document.
|
||||
*/
|
||||
static public final String STATEFUL_SOAP_12 = "application/vnd.sun.stateful.soap+fastinfoset";
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.encoding.fastinfoset;
|
||||
|
||||
import com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser;
|
||||
import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
||||
/**
|
||||
* @author Alexey Stashok
|
||||
*/
|
||||
public final class FastInfosetStreamReaderFactory extends XMLStreamReaderFactory {
|
||||
private static final FastInfosetStreamReaderFactory factory = new FastInfosetStreamReaderFactory();
|
||||
|
||||
private ThreadLocal<StAXDocumentParser> pool = new ThreadLocal<StAXDocumentParser>();
|
||||
|
||||
public static FastInfosetStreamReaderFactory getInstance() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
public XMLStreamReader doCreate(String systemId, InputStream in, boolean rejectDTDs) {
|
||||
StAXDocumentParser parser = fetch();
|
||||
if (parser == null) {
|
||||
return FastInfosetCodec.createNewStreamReaderRecyclable(in, false);
|
||||
}
|
||||
|
||||
parser.setInputStream(in);
|
||||
return parser;
|
||||
}
|
||||
|
||||
public XMLStreamReader doCreate(String systemId, Reader reader, boolean rejectDTDs) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private StAXDocumentParser fetch() {
|
||||
StAXDocumentParser parser = pool.get();
|
||||
pool.set(null);
|
||||
return parser;
|
||||
}
|
||||
|
||||
public void doRecycle(XMLStreamReader r) {
|
||||
if (r instanceof StAXDocumentParser) {
|
||||
pool.set((StAXDocumentParser) r);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.encoding.fastinfoset;
|
||||
|
||||
import com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser;
|
||||
import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author Alexey Stashok
|
||||
*/
|
||||
public final class FastInfosetStreamReaderRecyclable extends StAXDocumentParser implements XMLStreamReaderFactory.RecycleAware {
|
||||
private static final FastInfosetStreamReaderFactory READER_FACTORY = FastInfosetStreamReaderFactory.getInstance();
|
||||
|
||||
public FastInfosetStreamReaderRecyclable() {
|
||||
super();
|
||||
}
|
||||
|
||||
public FastInfosetStreamReaderRecyclable(InputStream in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
public void onRecycled() {
|
||||
READER_FACTORY.doRecycle(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.encoding.fastinfoset;
|
||||
|
||||
import com.sun.xml.internal.ws.api.pipe.ContentType;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.pipe.StreamSOAPCodec;
|
||||
import com.sun.xml.internal.ws.encoding.ContentTypeImpl;
|
||||
import com.sun.xml.internal.ws.message.stream.StreamHeader;
|
||||
import com.sun.xml.internal.ws.message.stream.StreamHeader11;
|
||||
import com.sun.xml.internal.stream.buffer.XMLStreamBuffer;
|
||||
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
||||
/**
|
||||
* A codec that converts SOAP 1.1 messages infosets to fast infoset
|
||||
* documents.
|
||||
*
|
||||
* @author Paul.Sandoz@Sun.Com
|
||||
*/
|
||||
final class FastInfosetStreamSOAP11Codec extends FastInfosetStreamSOAPCodec {
|
||||
/*package*/ FastInfosetStreamSOAP11Codec(StreamSOAPCodec soapCodec, boolean retainState) {
|
||||
super(soapCodec, SOAPVersion.SOAP_11, retainState,
|
||||
(retainState) ? FastInfosetMIMETypes.STATEFUL_SOAP_11 : FastInfosetMIMETypes.SOAP_11);
|
||||
}
|
||||
|
||||
private FastInfosetStreamSOAP11Codec(FastInfosetStreamSOAP11Codec that) {
|
||||
super(that);
|
||||
}
|
||||
|
||||
public Codec copy() {
|
||||
return new FastInfosetStreamSOAP11Codec(this);
|
||||
}
|
||||
|
||||
protected final StreamHeader createHeader(XMLStreamReader reader, XMLStreamBuffer mark) {
|
||||
return new StreamHeader11(reader, mark);
|
||||
}
|
||||
|
||||
protected ContentType getContentType(String soapAction) {
|
||||
if (soapAction == null || soapAction.length() == 0) {
|
||||
return _defaultContentType;
|
||||
} else {
|
||||
return new ContentTypeImpl(_defaultContentType.getContentType(), soapAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.encoding.fastinfoset;
|
||||
|
||||
import com.sun.xml.internal.ws.api.pipe.ContentType;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.pipe.StreamSOAPCodec;
|
||||
import com.sun.xml.internal.ws.encoding.ContentTypeImpl;
|
||||
import com.sun.xml.internal.ws.message.stream.StreamHeader;
|
||||
import com.sun.xml.internal.ws.message.stream.StreamHeader12;
|
||||
import com.sun.xml.internal.stream.buffer.XMLStreamBuffer;
|
||||
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
||||
/**
|
||||
* A codec that converts SOAP 1.2 messages infosets to fast infoset
|
||||
* documents.
|
||||
*
|
||||
* @author Paul.Sandoz@Sun.Com
|
||||
*/
|
||||
final class FastInfosetStreamSOAP12Codec extends FastInfosetStreamSOAPCodec {
|
||||
/*package*/ FastInfosetStreamSOAP12Codec(StreamSOAPCodec soapCodec, boolean retainState) {
|
||||
super(soapCodec, SOAPVersion.SOAP_12, retainState,
|
||||
(retainState) ? FastInfosetMIMETypes.STATEFUL_SOAP_12 : FastInfosetMIMETypes.SOAP_12);
|
||||
}
|
||||
|
||||
private FastInfosetStreamSOAP12Codec(FastInfosetStreamSOAPCodec that) {
|
||||
super(that);
|
||||
}
|
||||
|
||||
public Codec copy() {
|
||||
return new FastInfosetStreamSOAP12Codec(this);
|
||||
}
|
||||
|
||||
protected final StreamHeader createHeader(XMLStreamReader reader, XMLStreamBuffer mark) {
|
||||
return new StreamHeader12(reader, mark);
|
||||
}
|
||||
|
||||
protected ContentType getContentType(String soapAction) {
|
||||
if (soapAction == null) {
|
||||
return _defaultContentType;
|
||||
} else {
|
||||
return new ContentTypeImpl(
|
||||
_defaultContentType.getContentType() + ";action=\""+soapAction+"\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.encoding.fastinfoset;
|
||||
|
||||
import com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerializer;
|
||||
import com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.pipe.ContentType;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.pipe.StreamSOAPCodec;
|
||||
import com.sun.xml.internal.ws.message.stream.StreamHeader;
|
||||
import com.sun.xml.internal.stream.buffer.XMLStreamBuffer;
|
||||
import com.sun.xml.internal.ws.encoding.ContentTypeImpl;
|
||||
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
|
||||
/**
|
||||
* A stream SOAP codec for handling SOAP message infosets to fast
|
||||
* infoset documents.
|
||||
*
|
||||
* <p>
|
||||
* This implementation currently defers to {@link StreamSOAPCodec} for the decoding
|
||||
* using {@link XMLStreamReader}.
|
||||
*
|
||||
* @author Paul Sandoz
|
||||
*/
|
||||
public abstract class FastInfosetStreamSOAPCodec implements Codec {
|
||||
private static final FastInfosetStreamReaderFactory READER_FACTORY = FastInfosetStreamReaderFactory.getInstance();
|
||||
|
||||
private StAXDocumentParser _statefulParser;
|
||||
private StAXDocumentSerializer _serializer;
|
||||
|
||||
private final StreamSOAPCodec _soapCodec;
|
||||
|
||||
private final boolean _retainState;
|
||||
|
||||
protected final ContentType _defaultContentType;
|
||||
|
||||
/* package */ FastInfosetStreamSOAPCodec(StreamSOAPCodec soapCodec, SOAPVersion soapVersion, boolean retainState, String mimeType) {
|
||||
// _soapCodec = StreamSOAPCodec.create(soapVersion);
|
||||
_soapCodec = soapCodec;
|
||||
_retainState = retainState;
|
||||
_defaultContentType = new ContentTypeImpl(mimeType);
|
||||
}
|
||||
|
||||
/* package */ FastInfosetStreamSOAPCodec(FastInfosetStreamSOAPCodec that) {
|
||||
this._soapCodec = (StreamSOAPCodec) that._soapCodec.copy();
|
||||
this._retainState = that._retainState;
|
||||
this._defaultContentType = that._defaultContentType;
|
||||
}
|
||||
|
||||
public String getMimeType() {
|
||||
return _defaultContentType.getContentType();
|
||||
}
|
||||
|
||||
public ContentType getStaticContentType(Packet packet) {
|
||||
return getContentType(packet.soapAction);
|
||||
}
|
||||
|
||||
public ContentType encode(Packet packet, 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 ContentType encode(Packet packet, WritableByteChannel buffer) {
|
||||
//TODO: not yet implemented
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void decode(InputStream in, String contentType, Packet response) throws IOException {
|
||||
response.setMessage(
|
||||
_soapCodec.decode(getXMLStreamReader(in)));
|
||||
}
|
||||
|
||||
public void decode(ReadableByteChannel in, String contentType, Packet response) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
protected abstract StreamHeader createHeader(XMLStreamReader reader, XMLStreamBuffer mark);
|
||||
|
||||
protected abstract ContentType getContentType(String soapAction);
|
||||
|
||||
private XMLStreamWriter getXMLStreamWriter(OutputStream out) {
|
||||
if (_serializer != null) {
|
||||
_serializer.setOutputStream(out);
|
||||
return _serializer;
|
||||
} else {
|
||||
return _serializer = FastInfosetCodec.createNewStreamWriter(out, _retainState);
|
||||
}
|
||||
}
|
||||
|
||||
private XMLStreamReader getXMLStreamReader(InputStream in) {
|
||||
// If the _retainState is true (FI stateful) then pick up Codec assiciated XMLStreamReader
|
||||
if (_retainState) {
|
||||
if (_statefulParser != null) {
|
||||
_statefulParser.setInputStream(in);
|
||||
return _statefulParser;
|
||||
} else {
|
||||
return _statefulParser = FastInfosetCodec.createNewStreamReader(in, _retainState);
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise thread assiciated XMLStreamReader
|
||||
return READER_FACTORY.doCreate(null, in, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link FastInfosetStreamSOAPCodec} instance.
|
||||
*
|
||||
* @param version the SOAP version of the codec.
|
||||
* @return a new {@link FastInfosetStreamSOAPCodec} instance.
|
||||
*/
|
||||
public static FastInfosetStreamSOAPCodec create(StreamSOAPCodec soapCodec, SOAPVersion version) {
|
||||
return create(soapCodec, version, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link FastInfosetStreamSOAPCodec} instance.
|
||||
*
|
||||
* @param version the SOAP version of the codec.
|
||||
* @param retainState if true the Codec should retain the state of
|
||||
* vocabulary tables for multiple encode/decode invocations.
|
||||
* @return a new {@link FastInfosetStreamSOAPCodec} instance.
|
||||
*/
|
||||
public static FastInfosetStreamSOAPCodec create(StreamSOAPCodec soapCodec,
|
||||
SOAPVersion version, boolean retainState) {
|
||||
if(version==null)
|
||||
// this decoder is for SOAP, not for XML/HTTP
|
||||
throw new IllegalArgumentException();
|
||||
switch(version) {
|
||||
case SOAP_11:
|
||||
return new FastInfosetStreamSOAP11Codec(soapCodec, retainState);
|
||||
case SOAP_12:
|
||||
return new FastInfosetStreamSOAP12Codec(soapCodec, retainState);
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user