Package org.apache.cxf.io

Examples of org.apache.cxf.io.CachedOutputStream$TransferableFileInputStream


        HttpURLConnection httpConnection =
            getHttpConnection("http://localhost:" + PORT2 + "/test.html");   
        httpConnection.connect();
        InputStream in = httpConnection.getInputStream();       
        assertNotNull(in);
        CachedOutputStream response = new CachedOutputStream();
        IOUtils.copy(in, response);
        in.close();
        response.close();
             
        FileInputStream htmlFile =
            new FileInputStream("target/test-classes/org/apache/cxf/systest/http_jetty/test.html");   
        CachedOutputStream html = new CachedOutputStream();
        IOUtils.copy(htmlFile, html);
        htmlFile.close();
        html.close();
       
        assertEquals("Can't get the right test html", html.toString(), response.toString());
    }
View Full Code Here


                                                                       contextMatchOnExact())
                    : qh.isRecognizedQuery(requestURL, pathInfo, endpointInfo);
                if (recognized) {
                    //replace the endpointInfo address with request url only for get wsdl
                    String errorMsg = null;
                    CachedOutputStream out = new CachedOutputStream();
                    try {
                        synchronized (endpointInfo) {
                            String oldAddress = updateEndpointAddress(reqAddr);  
                            resp.setContentType(qh.getResponseContentType(requestURL, pathInfo));
                            try {
                                qh.writeResponse(requestURL, pathInfo, endpointInfo, out);
                            } catch (Exception ex) {
                                LOG.log(Level.WARNING, "writeResponse failed: ", ex);
                                errorMsg = ex.getMessage();
                            }
                            endpointInfo.setAddress(oldAddress);
                        }
                        if (errorMsg != null) {
                            resp.sendError(500, errorMsg);
                        } else {
                            out.writeCacheTo(resp.getOutputStream());
                            resp.getOutputStream().flush();                    
                        }
                    } finally {
                        out.close();
                    }
                    baseRequest.setHandled(true);
                    return;
                }
            }
View Full Code Here

    private void cache(DelegatingInputStream input, boolean deleteOnClose) throws IOException {
        if (loaded.contains(input)) {
            return;
        }
        loaded.add(input);
        CachedOutputStream out = null;
        InputStream origIn = input.getInputStream();
        try {
            out = new CachedOutputStream();
            setStreamedAttachmentProperties(out);
            IOUtils.copy(input, out);
            input.setInputStream(out.getInputStream());
            origIn.close();
        } finally {
            if (out != null) {
                out.close();
            }
        }
    }
View Full Code Here

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

        HttpURLConnection httpConnection =
            getHttpConnection("http://localhost:8808/test.html");   
        httpConnection.connect();
        InputStream in = httpConnection.getInputStream();       
        assertNotNull(in);
        CachedOutputStream response = new CachedOutputStream();
        IOUtils.copy(in, response);
        in.close();
        response.close();
             
        FileInputStream htmlFile =
            new FileInputStream("target/test-classes/org/apache/cxf/systest/http_jetty/test.html");   
        CachedOutputStream html = new CachedOutputStream();
        IOUtils.copy(htmlFile, html);
        htmlFile.close();
        html.close();
       
        assertEquals("Can't get the right test html", html.toString(), response.toString());
    }
View Full Code Here

                endpoint.getHeaderFilterStrategy(), exchange, false);
        org.apache.cxf.message.Exchange cxfExchange = outMessage.getExchange();
        InterceptorChain chain = OutgoingChainInterceptor.getOutInterceptorChain(cxfExchange);
        outMessage.setInterceptorChain(chain);
        chain.doIntercept(outMessage);
        CachedOutputStream outputStream = (CachedOutputStream)outMessage.getContent(OutputStream.class);
        exchange.getOut().setBody(outputStream.getInputStream());
    }
View Full Code Here

        outMessage.put(Message.INBOUND_MESSAGE, Boolean.FALSE);
        InterceptorChain chain = OutgoingChainInterceptor.getOutInterceptorChain(cxfExchange);
        outMessage.setInterceptorChain(chain);

        chain.doIntercept(outMessage);
        CachedOutputStream outputStream = (CachedOutputStream)outMessage.getContent(OutputStream.class);
        exchange.getOut().setBody(outputStream.getInputStream());
        exchange.getIn().setBody(outputStream.getInputStream());
    }
View Full Code Here

            }
            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

            get.releaseConnection();
        }
    }
   
    private InputStream copyIn(InputStream in) throws Exception {
        CachedOutputStream bos = new CachedOutputStream();
        IOUtils.copy(in, bos);
        in.close();
        in = bos.getInputStream();
        bos.close();
        return in;
    }
View Full Code Here

TOP

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

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.