Java源码示例:com.sun.xml.internal.ws.api.pipe.Codec
示例1
private Packet decodePacket(@NotNull WSHTTPConnection con, @NotNull Codec codec) throws IOException {
String ct = con.getRequestHeader("Content-Type");
InputStream in = con.getInput();
Packet packet = new Packet();
packet.soapAction = fixQuotesAroundSoapAction(con.getRequestHeader("SOAPAction"));
packet.wasTransportSecure = con.isSecure();
packet.acceptableMimeTypes = con.getRequestHeader("Accept");
packet.addSatellite(con);
addSatellites(packet);
packet.isAdapterDeliversNonAnonymousResponse = true;
packet.component = this;
packet.transportBackChannel = new Oneway(con);
packet.webServiceContextDelegate = con.getWebServiceContextDelegate();
packet.setState(Packet.State.ServerRequest);
if (dump || LOGGER.isLoggable(Level.FINER)) {
ByteArrayBuffer buf = new ByteArrayBuffer();
buf.write(in);
in.close();
dump(buf, "HTTP request", con.getRequestHeaders());
in = buf.newInputStream();
}
codec.decode(in, ct, packet);
return packet;
}
示例2
public ContentType getStaticContentType(Packet packet) {
ContentType ct = (ContentType) packet.getInternalContentType();
if ( ct != null ) return ct;
Message msg = packet.getMessage();
boolean hasAttachments = !msg.getAttachments().isEmpty();
Codec rootCodec = getMimeRootCodec(packet);
if (hasAttachments) {
String boundary = "uuid:" + UUID.randomUUID().toString();
String boundaryParameter = "boundary=\"" + boundary + "\"";
// TODO use primaryEncoder to get type
String messageContentType = MULTIPART_RELATED_MIME_TYPE +
"; type=\"" + rootCodec.getMimeType() + "\"; " +
boundaryParameter;
ContentTypeImpl impl = new ContentTypeImpl(messageContentType, packet.soapAction, null);
impl.setBoundary(boundary);
impl.setBoundaryParameter(boundaryParameter);
packet.setContentType(impl);
return impl;
} else {
ct = rootCodec.getStaticContentType(packet);
packet.setContentType(ct);
return ct;
}
}
示例3
/**
* Reads and decodes infoset from the connection and invokes the endpoints. The
* response is encoded and written to the connection. The response could be
* written using a different thread.
*
* @param connection that carries the web service request
* @throws IOException if an i/o error happens while encoding/decoding
*/
protected void handle(final T connection) throws IOException {
final Codec codec = codecPool.take();
Packet request = decodePacket(connection, codec);
if (!request.getMessage().isFault()) {
endpoint.schedule(request, new WSEndpoint.CompletionCallback() {
public void onCompletion(@NotNull Packet response) {
try {
encodePacket(connection, response, codec);
} catch(IOException ioe) {
ioe.printStackTrace();
}
codecPool.recycle(codec);
}
});
}
}
示例4
private Packet decodePacket(@NotNull WSHTTPConnection con, @NotNull Codec codec) throws IOException {
String ct = con.getRequestHeader("Content-Type");
InputStream in = con.getInput();
Packet packet = new Packet();
packet.soapAction = fixQuotesAroundSoapAction(con.getRequestHeader("SOAPAction"));
packet.wasTransportSecure = con.isSecure();
packet.acceptableMimeTypes = con.getRequestHeader("Accept");
packet.addSatellite(con);
addSatellites(packet);
packet.isAdapterDeliversNonAnonymousResponse = true;
packet.component = this;
packet.transportBackChannel = new Oneway(con);
packet.webServiceContextDelegate = con.getWebServiceContextDelegate();
packet.setState(Packet.State.ServerRequest);
if (dump || LOGGER.isLoggable(Level.FINER)) {
ByteArrayBuffer buf = new ByteArrayBuffer();
buf.write(in);
in.close();
dump(buf, "HTTP request", con.getRequestHeaders());
in = buf.newInputStream();
}
codec.decode(in, ct, packet);
return packet;
}
示例5
public ContentType getStaticContentType(Packet packet) {
ContentType ct = (ContentType) packet.getInternalContentType();
if ( ct != null ) return ct;
Message msg = packet.getMessage();
boolean hasAttachments = !msg.getAttachments().isEmpty();
Codec rootCodec = getMimeRootCodec(packet);
if (hasAttachments) {
String boundary = "uuid:" + UUID.randomUUID().toString();
String boundaryParameter = "boundary=\"" + boundary + "\"";
// TODO use primaryEncoder to get type
String messageContentType = MULTIPART_RELATED_MIME_TYPE +
"; type=\"" + rootCodec.getMimeType() + "\"; " +
boundaryParameter;
ContentTypeImpl impl = new ContentTypeImpl(messageContentType, packet.soapAction, null);
impl.setBoundary(boundary);
impl.setBoundaryParameter(boundaryParameter);
packet.setContentType(impl);
return impl;
} else {
ct = rootCodec.getStaticContentType(packet);
packet.setContentType(ct);
return ct;
}
}
示例6
private Packet decodePacket(@NotNull WSHTTPConnection con, @NotNull Codec codec) throws IOException {
String ct = con.getRequestHeader("Content-Type");
InputStream in = con.getInput();
Packet packet = new Packet();
packet.soapAction = fixQuotesAroundSoapAction(con.getRequestHeader("SOAPAction"));
packet.wasTransportSecure = con.isSecure();
packet.acceptableMimeTypes = con.getRequestHeader("Accept");
packet.addSatellite(con);
addSatellites(packet);
packet.isAdapterDeliversNonAnonymousResponse = true;
packet.component = this;
packet.transportBackChannel = new Oneway(con);
packet.webServiceContextDelegate = con.getWebServiceContextDelegate();
packet.setState(Packet.State.ServerRequest);
if (dump || LOGGER.isLoggable(Level.FINER)) {
ByteArrayBuffer buf = new ByteArrayBuffer();
buf.write(in);
in.close();
dump(buf, "HTTP request", con.getRequestHeaders());
in = buf.newInputStream();
}
codec.decode(in, ct, packet);
return packet;
}
示例7
public ContentType getStaticContentType(Packet packet) {
ContentType ct = (ContentType) packet.getInternalContentType();
if ( ct != null ) return ct;
Message msg = packet.getMessage();
boolean hasAttachments = !msg.getAttachments().isEmpty();
Codec rootCodec = getMimeRootCodec(packet);
if (hasAttachments) {
String boundary = "uuid:" + UUID.randomUUID().toString();
String boundaryParameter = "boundary=\"" + boundary + "\"";
// TODO use primaryEncoder to get type
String messageContentType = MULTIPART_RELATED_MIME_TYPE +
"; type=\"" + rootCodec.getMimeType() + "\"; " +
boundaryParameter;
ContentTypeImpl impl = new ContentTypeImpl(messageContentType, packet.soapAction, null);
impl.setBoundary(boundary);
impl.setBoundaryParameter(boundaryParameter);
packet.setContentType(impl);
return impl;
} else {
ct = rootCodec.getStaticContentType(packet);
packet.setContentType(ct);
return ct;
}
}
示例8
public ContentType getStaticContentType(Packet packet) {
ContentType ct = (ContentType) packet.getInternalContentType();
if ( ct != null ) return ct;
Message msg = packet.getMessage();
boolean hasAttachments = !msg.getAttachments().isEmpty();
Codec rootCodec = getMimeRootCodec(packet);
if (hasAttachments) {
String boundary = "uuid:" + UUID.randomUUID().toString();
String boundaryParameter = "boundary=\"" + boundary + "\"";
// TODO use primaryEncoder to get type
String messageContentType = MULTIPART_RELATED_MIME_TYPE +
"; type=\"" + rootCodec.getMimeType() + "\"; " +
boundaryParameter;
ContentTypeImpl impl = new ContentTypeImpl(messageContentType, packet.soapAction, null);
impl.setBoundary(boundary);
impl.setBoundaryParameter(boundaryParameter);
packet.setContentType(impl);
return impl;
} else {
ct = rootCodec.getStaticContentType(packet);
packet.setContentType(ct);
return ct;
}
}
示例9
@Override
protected Codec getMimeRootCodec(Packet p) {
/**
* The following logic is only for outbound packets
* to be encoded by client.
* On the server the p.contentNegotiation == null.
*/
if (p.contentNegotiation == ContentNegotiation.none) {
// The client may have changed the negotiation property from
// pessismistic to none between invocations
useFastInfosetForEncoding = false;
} else if (p.contentNegotiation == ContentNegotiation.optimistic) {
// Always encode using Fast Infoset if in optimisitic mode
useFastInfosetForEncoding = true;
}
return (useFastInfosetForEncoding && fiCodec != null)? fiCodec : xmlCodec;
}
示例10
@NotNull
public final Codec createCodec() {
// initialization from here should cover most of cases;
// if not, it would be necessary to call
// BindingImpl.initializeJavaActivationHandlers()
// explicitly by programmer
initializeJavaActivationHandlers();
return bindingId.createEncoder(this);
}
示例11
/**
* Obtain an FI SOAP codec instance using reflection.
*/
private static Codec getFICodec(StreamSOAPCodec soapCodec, SOAPVersion version) {
try {
Class c = Class.forName("com.sun.xml.internal.ws.encoding.fastinfoset.FastInfosetStreamSOAPCodec");
Method m = c.getMethod("create", StreamSOAPCodec.class, SOAPVersion.class);
return (Codec)m.invoke(null, soapCodec, version);
} catch (Exception e) {
// TODO Log that FI cannot be loaded
return null;
}
}
示例12
/**
* Obtain an FI SOAP codec instance using reflection.
*/
private static Codec getFICodec() {
try {
Class c = Class.forName("com.sun.xml.internal.ws.encoding.fastinfoset.FastInfosetCodec");
Method m = c.getMethod("create");
return (Codec)m.invoke(null);
} catch (Exception e) {
return null;
}
}
示例13
@NotNull
public final Codec createCodec() {
// initialization from here should cover most of cases;
// if not, it would be necessary to call
// BindingImpl.initializeJavaActivationHandlers()
// explicitly by programmer
initializeJavaActivationHandlers();
return bindingId.createEncoder(this);
}
示例14
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
// TODO: handle attachments correctly
Attachment root = mpp.getRootPart();
Codec rootCodec = getMimeRootCodec(packet);
if (rootCodec instanceof RootOnlyCodec) {
((RootOnlyCodec)rootCodec).decode(root.asInputStream(),root.getContentType(),packet, new MimeAttachmentSet(mpp));
} else {
rootCodec.decode(root.asInputStream(),root.getContentType(),packet);
Map<String, Attachment> atts = mpp.getAttachmentParts();
for(Map.Entry<String, Attachment> att : atts.entrySet()) {
packet.getMessage().getAttachments().add(att.getValue());
}
}
}
示例15
/**
* Obtain an FI SOAP codec instance using reflection.
*/
private static Codec getFICodec() {
try {
Class c = Class.forName("com.sun.xml.internal.ws.encoding.fastinfoset.FastInfosetCodec");
Method m = c.getMethod("create");
return (Codec)m.invoke(null);
} catch (Exception e) {
return null;
}
}
示例16
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
// TODO: handle attachments correctly
Attachment root = mpp.getRootPart();
Codec rootCodec = getMimeRootCodec(packet);
if (rootCodec instanceof RootOnlyCodec) {
((RootOnlyCodec)rootCodec).decode(root.asInputStream(),root.getContentType(),packet, new MimeAttachmentSet(mpp));
} else {
rootCodec.decode(root.asInputStream(),root.getContentType(),packet);
Map<String, Attachment> atts = mpp.getAttachmentParts();
for(Map.Entry<String, Attachment> att : atts.entrySet()) {
packet.getMessage().getAttachments().add(att.getValue());
}
}
}
示例17
@NotNull
public final Codec createCodec() {
// initialization from here should cover most of cases;
// if not, it would be necessary to call
// BindingImpl.initializeJavaActivationHandlers()
// explicitly by programmer
initializeJavaActivationHandlers();
return bindingId.createEncoder(this);
}
示例18
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
// TODO: handle attachments correctly
Attachment root = mpp.getRootPart();
Codec rootCodec = getMimeRootCodec(packet);
if (rootCodec instanceof RootOnlyCodec) {
((RootOnlyCodec)rootCodec).decode(root.asInputStream(),root.getContentType(),packet, new MimeAttachmentSet(mpp));
} else {
rootCodec.decode(root.asInputStream(),root.getContentType(),packet);
Map<String, Attachment> atts = mpp.getAttachmentParts();
for(Map.Entry<String, Attachment> att : atts.entrySet()) {
packet.getMessage().getAttachments().add(att.getValue());
}
}
}
示例19
/**
* Obtain an FI SOAP codec instance using reflection.
*/
private static Codec getFICodec() {
try {
Class c = Class.forName("com.sun.xml.internal.ws.encoding.fastinfoset.FastInfosetCodec");
Method m = c.getMethod("create");
return (Codec)m.invoke(null);
} catch (Exception e) {
return null;
}
}
示例20
protected Codec create() {
return endpoint.createCodec();
}
示例21
protected Codec create() {
return endpoint.createCodec();
}
示例22
Codec getCodec() {
if (codec == null) {
codec = ((BindingImpl) seiModel.getWSBinding()).createCodec();
}
return codec;
}
示例23
@Override
public Codec createEncoder(WSBinding binding) {
return new XMLHTTPBindingCodec(binding.getFeatures());
}
示例24
Codec getCodec() {
if (codec == null) {
codec = ((BindingImpl) seiModel.getWSBinding()).createCodec();
}
return codec;
}
示例25
@Override
public Codec createEncoder(WSBinding binding) {
return new XMLHTTPBindingCodec(binding.getFeatures());
}
示例26
@Override
public Codec createEncoder(WSBinding binding) {
return new XMLHTTPBindingCodec(binding.getFeatures());
}
示例27
public @NotNull @Override Codec createEncoder(WSBinding binding) {
return new SOAPBindingCodec(binding.getFeatures());
}
示例28
Codec getCodec() {
if (codec == null) {
codec = ((BindingImpl) seiModel.getWSBinding()).createCodec();
}
return codec;
}
示例29
protected Codec create() {
return endpoint.createCodec();
}
示例30
public Codec copy() {
return new FastInfosetStreamSOAP12Codec(this);
}