Package org.apache.cxf.io

Examples of org.apache.cxf.io.CachedOutputStream


            }
            getLogger().log(Level.FINE, "send the message to endpoint" + targetCamelEndpointUri);
            // We could wait for the rely asynchronously
            org.apache.camel.Exchange exchange = getCamelTemplate().send(targetCamelEndpointUri, pattern, new Processor() {
                public void process(org.apache.camel.Exchange ex) throws IOException {
                    CachedOutputStream outputStream = (CachedOutputStream)outMessage.getContent(OutputStream.class);
                    // Send out the request message here, copy the protocolHeader back
                    CxfHeaderHelper.propagateCxfToCamel(headerFilterStrategy, outMessage, ex.getIn().getHeaders());
                    // TODO support different encoding
                    ex.getIn().setBody(outputStream.getBytes());
                    getLogger().log(Level.FINE, "template sending request: ", ex.getIn());
                }
            });
            exchange.setProperty(CxfConstants.CXF_EXCHANGE, outMessage.getExchange());
            if (!isOneWay) {
View Full Code Here


        // Prepare the message and get the send out message
        private void commitOutputMessage() throws IOException {
            Exchange camelExchange = (Exchange)outMessage.get(CxfConstants.CAMEL_EXCHANGE);
           
            CxfHeaderHelper.propagateCxfToCamel(headerFilterStrategy, outMessage, camelExchange.getOut().getHeaders());
            CachedOutputStream outputStream = (CachedOutputStream)outMessage.getContent(OutputStream.class);
            camelExchange.getOut().setBody(outputStream.getBytes());
            getLogger().log(Level.FINE, "send the response message: " + outputStream);

        }
View Full Code Here

        File requestFile = new File(request.toURI());
        FileInputStream inputStream = new FileInputStream(requestFile);
        Object result = template.sendBody("direct:consumer", inputStream);
        assertFalse("The result should not be changed", inputStream.equals(result));
        assertTrue("result should be a inputstream", result instanceof InputStream);
        CachedOutputStream bos = new CachedOutputStream();
        IOUtils.copy((InputStream) result, bos);
        bos.flush();
        ((InputStream)result).close();
        assertEquals("We should find the soap body string here",
                   SOAP_STRING, bos.getOut().toString());


    }
View Full Code Here

            boolean streamingOn = configurableProvider
                ? ((AbstractConfigurableProvider)w).getEnableStreaming() : false;
            if (streamingOn) {
                m.setContent(XMLStreamWriter.class, new CachingXmlEventWriter());
            } else {
                m.setContent(OutputStream.class, new CachedOutputStream());
            }
        }
        return enabled;
    }
View Full Code Here

            return;
        }
        if (enabled) {
            OutputStream os = m.getContent(OutputStream.class);
            if (os != osOriginal && os instanceof CachedOutputStream) {
                CachedOutputStream cos = (CachedOutputStream)os;
                if (cos.size() != 0) {
                    cos.writeCacheTo(osOriginal);
                }
            }
        }
    }
View Full Code Here

   
    public static void restoreForm(FormEncodingProvider<Form> provider,
                                   Form form,
                                   Message message)
        throws Exception {
        CachedOutputStream os = new CachedOutputStream();
        writeForm(provider, form, os);
        message.setContent(InputStream.class, os.getInputStream());
    }
View Full Code Here

        }
    }

    protected Object unmarshalFromReader(Unmarshaller unmarshaller, XMLStreamReader reader, MediaType mt)
        throws JAXBException {
        CachedOutputStream out = new CachedOutputStream();
        try {
            XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out);
            StaxUtils.copy(new StaxSource(reader), writer);
            writer.writeEndDocument();
            writer.flush();
            writer.close();
            return unmarshalFromInputStream(unmarshaller, out.getInputStream(), mt);
        } catch (Exception ex) {
            throw ExceptionUtils.toBadRequestException(ex, null);
        }
    }
View Full Code Here

    }
   
    @Override
    protected void marshalToWriter(Marshaller ms, Object obj, XMLStreamWriter writer, MediaType mt)
        throws Exception {
        CachedOutputStream out = new CachedOutputStream();
        marshalToOutputStream(ms, obj, out, mt);
       
        StaxUtils.copy(new StreamSource(out.getInputStream()), writer);
    }
View Full Code Here

    }
   
    private InputStream getStreamFromReader(XMLStreamReader input)
        throws IOException {
       
        CachedOutputStream out = new CachedOutputStream();
        try {
            StaxUtils.copy(input, out);
            return out.getInputStream();
        } catch (XMLStreamException ex) {
            throw new IOException("XMLStreamException:" + ex.getMessage());
        } finally {
            out.close();
        }
    }
View Full Code Here

        }
        return str;
    }
   
    private String getStringFromInputStream(InputStream in) throws Exception {       
        CachedOutputStream bos = new CachedOutputStream();
        IOUtils.copy(in, bos);
        String str = new String(bos.getBytes());
        in.close();
        bos.close();
        return str;
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.io.CachedOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.