com.sun.xml.internal.ws.api.pipe.Codec Java Examples

The following examples show how to use com.sun.xml.internal.ws.api.pipe.Codec. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpAdapter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: MimeCodec.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #3
Source File: HttpAdapter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: HttpAdapter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: MimeCodec.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #6
Source File: MimeCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #7
Source File: MimeCodec.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #8
Source File: XMLHTTPBindingCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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;
}
 
Example #9
Source File: AbstractServerAsyncTransport.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
            }
        });
    }
}
 
Example #10
Source File: BindingImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #11
Source File: SOAPBindingCodec.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
    }
}
 
Example #12
Source File: SwACodec.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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());
        }
    }
}
 
Example #13
Source File: XMLHTTPBindingCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
    }
}
 
Example #14
Source File: BindingImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #15
Source File: BindingImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #16
Source File: XMLHTTPBindingCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
    }
}
 
Example #17
Source File: SwACodec.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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());
        }
    }
}
 
Example #18
Source File: SwACodec.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@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());
        }
    }
}
 
Example #19
Source File: XMLHTTPBindingCodec.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
    }
}
 
Example #20
Source File: DatabindingImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
Codec getCodec() {
    if (codec == null) {
        codec = ((BindingImpl) seiModel.getWSBinding()).createCodec();
    }
    return codec;
}
 
Example #21
Source File: FastInfosetCodec.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public Codec copy() {
    return new FastInfosetCodec(_retainState);
}
 
Example #22
Source File: XMLCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public Codec copy() {
    return this;
}
 
Example #23
Source File: SwACodec.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public SwACodec(SOAPVersion version, WSFeatureList f, Codec rootCodec) {
    super(version, f);
    this.mimeRootCodec = rootCodec;
}
 
Example #24
Source File: SwACodec.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public SwACodec(SOAPVersion version, WSFeatureList f, Codec rootCodec) {
    super(version, f);
    this.mimeRootCodec = rootCodec;
}
 
Example #25
Source File: FastInfosetStreamSOAP11Codec.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public Codec copy() {
    return new FastInfosetStreamSOAP11Codec(this);
}
 
Example #26
Source File: HttpAdapter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void encodePacket(WSHTTPConnection con, @NotNull Packet packet, @NotNull Codec codec) throws IOException {
    HttpAdapter.this.encodePacket(packet, con, codec);
}
 
Example #27
Source File: MimeCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected Codec getMimeRootCodec(Packet packet) {
    return mimeRootCodec;
}
 
Example #28
Source File: BindingID.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Codec createEncoder(WSBinding binding) {
    return new XMLHTTPBindingCodec(binding.getFeatures());
}
 
Example #29
Source File: FastInfosetStreamSOAP11Codec.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public Codec copy() {
    return new FastInfosetStreamSOAP11Codec(this);
}
 
Example #30
Source File: FastInfosetStreamSOAP11Codec.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public Codec copy() {
    return new FastInfosetStreamSOAP11Codec(this);
}