Examples of LoadingByteArrayOutputStream


Examples of org.apache.camel.component.http.helper.LoadingByteArrayOutputStream

    protected int executeMethod(HttpMethod method) throws IOException {
        return httpClient.executeMethod(method);
    }

    protected static InputStream extractResponseBody(HttpMethod method) throws IOException {
        LoadingByteArrayOutputStream bos = null;
        InputStream is = null;
        try {
            bos = new LoadingByteArrayOutputStream();
            is = method.getResponseBodyAsStream();
            IOUtils.copy(is, bos);
            bos.flush();
            return bos.createInputStream();
        } finally {
            ObjectHelper.close(is, "Extracting response body", LOG);
            ObjectHelper.close(bos, "Extracting response body", LOG);
        }
    }
View Full Code Here

Examples of org.apache.camel.component.http.helper.LoadingByteArrayOutputStream

     * @param method  the method that was executed
     * @return  the response as a stream
     * @throws IOException can be thrown
     */
    protected static InputStream extractResponseBody(HttpMethod method) throws IOException {
        LoadingByteArrayOutputStream bos = null;
        InputStream is = null;
        try {
            bos = new LoadingByteArrayOutputStream();
            is = method.getResponseBodyAsStream();
            // in case of no response stream
            if (is == null) {
                return null;
            }
            IOUtils.copy(is, bos);
            bos.flush();
            return bos.createInputStream();
        } finally {
            ObjectHelper.close(is, "Extracting response body", LOG);
            ObjectHelper.close(bos, "Extracting response body", LOG);
        }
    }
View Full Code Here

Examples of org.apache.camel.component.http.helper.LoadingByteArrayOutputStream

        HttpMethod method = createMethod();

        try {
            int responseCode = httpClient.executeMethod(method);
            // lets store the result in the output message.
            LoadingByteArrayOutputStream bos = new LoadingByteArrayOutputStream();
            InputStream is = method.getResponseBodyAsStream();
            IOUtils.copy(is, bos);
            bos.flush();
            is.close();
            Message message = exchange.getIn();
            message.setBody(bos.createInputStream());

            // lets set the headers
            Header[] headers = method.getResponseHeaders();
            HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
            for (Header header : headers) {
View Full Code Here

Examples of org.apache.camel.component.http4.helper.LoadingByteArrayOutputStream

        try {
            HttpResponse response = httpClient.execute(method);
            int responseCode = response.getStatusLine().getStatusCode();
            responeEntity = response.getEntity();
            // lets store the result in the output message.
            LoadingByteArrayOutputStream bos = new LoadingByteArrayOutputStream();
            InputStream is = responeEntity.getContent();

            try {
                IOHelper.copy(is, bos);
                bos.flush();
            } finally {
                ObjectHelper.close(is, "input stream", null);
            }
            Message message = exchange.getIn();
            message.setBody(bos.createInputStream());

            // lets set the headers
            Header[] headers = response.getAllHeaders();
            HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
            for (Header header : headers) {
View Full Code Here

Examples of org.apache.cxf.helpers.LoadingByteArrayOutputStream

                    if (baseURI == null) {
                        baseURI = si.getSystemId();
                    }
                    DOMSource ds = new DOMSource(el, baseURI);  
                    schemaSourcesMap2.put(si.getSystemId() + ":" + si.getNamespaceURI(), ds);
                    LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream();
                    StaxUtils.copy(el, StaxUtils.createXMLStreamWriter(out));
                    schemaSourcesMap.put(si.getSystemId() + ":" + si.getNamespaceURI(), out.toByteArray());
                }

               
                for (XmlSchema sch : serviceInfo.getXmlSchemaCollection().getXmlSchemas()) {
                    if (sch.getSourceURI() != null
                        && !schemaSourcesMap.containsKey(sch.getSourceURI() + ":"
                                                         + sch.getTargetNamespace())) {
                       
                        InputStream ins = null;
                        try {
                            URL url = new URL(sch.getSourceURI());
                            ins = url.openStream();
                        } catch (Exception e) {
                            //ignore, we'll just use what we have.  (though
                            //bugs in XmlSchema could make this less useful)
                        }
                       
                        LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream();
                        if (ins == null) {
                            sch.write(out);
                        } else {
                            IOUtils.copyAndCloseInput(ins, out);
                        }

                        schemaSourcesMap.put(sch.getSourceURI() + ":"
                                             + sch.getTargetNamespace(), out.toByteArray());
                       
                        Source source = new StreamSource(out.createInputStream(), sch.getSourceURI());
                        schemaSourcesMap2.put(sch.getSourceURI() + ":"
                                              + sch.getTargetNamespace(), source);
                    }
                }
View Full Code Here

Examples of org.apache.cxf.helpers.LoadingByteArrayOutputStream

         */
        public void close() throws IOException {
            try {
                if (buffer != null && buffer.size() > 0) {
                    thresholdNotReached();
                    LoadingByteArrayOutputStream tmp = buffer;
                    buffer = null;
                    super.write(tmp.getRawBytes(), 0, tmp.size());
                }
                boolean exceptionSet = outMessage.getContent(Exception.class) != null;
                if (!written && !exceptionSet) {
                    handleHeadersTrustCaching();
                }
View Full Code Here

Examples of org.apache.cxf.helpers.LoadingByteArrayOutputStream

                    if (baseURI == null) {
                        baseURI = si.getSystemId();
                    }
                    DOMSource ds = new DOMSource(el, baseURI);  
                    schemaSourcesMap2.put(si.getSystemId() + ":" + si.getNamespaceURI(), ds);
                    LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream();
                    writer = StaxUtils.createXMLStreamWriter(out);
                    StaxUtils.copy(el, writer);
                    writer.flush();
                    schemaSourcesMap.put(si.getSystemId() + ":" + si.getNamespaceURI(), out.toByteArray());
                }

               
                for (XmlSchema sch : serviceInfo.getXmlSchemaCollection().getXmlSchemas()) {
                    if (sch.getSourceURI() != null
                        && !schemaSourcesMap.containsKey(sch.getSourceURI() + ":"
                                                         + sch.getTargetNamespace())) {
                       
                        InputStream ins = null;
                        try {
                            URL url = new URL(sch.getSourceURI());
                            ins = url.openStream();
                        } catch (Exception e) {
                            //ignore, we'll just use what we have.  (though
                            //bugs in XmlSchema could make this less useful)
                        }
                       
                        LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream();
                        if (ins == null) {
                            sch.write(out);
                        } else {
                            IOUtils.copyAndCloseInput(ins, out);
                        }

                        schemaSourcesMap.put(sch.getSourceURI() + ":"
                                             + sch.getTargetNamespace(), out.toByteArray());
                       
                        Source source = new StreamSource(out.createInputStream(), sch.getSourceURI());
                        schemaSourcesMap2.put(sch.getSourceURI() + ":"
                                              + sch.getTargetNamespace(), source);
                    }
                }
View Full Code Here

Examples of org.apache.cxf.helpers.LoadingByteArrayOutputStream

        this(defaultThreshold);
    }

    public CachedOutputStream(long threshold) {
        this.threshold = threshold;
        currentStream = new LoadingByteArrayOutputStream(2048);
        inmem = true;
        readBusProperties();
    }
View Full Code Here

Examples of org.apache.cxf.helpers.LoadingByteArrayOutputStream

     * @param copyOldContent flag indicating if the old content should be copied
     * @throws IOException
     */
    public void resetOut(OutputStream out, boolean copyOldContent) throws IOException {
        if (out == null) {
            out = new LoadingByteArrayOutputStream();
        }

        if (currentStream instanceof CachedOutputStream) {
            CachedOutputStream ac = (CachedOutputStream) currentStream;
            InputStream in = ac.getInputStream();
View Full Code Here

Examples of org.apache.cxf.helpers.LoadingByteArrayOutputStream

        }

        long count = 0;
        if (inmem) {
            if (currentStream instanceof LoadingByteArrayOutputStream) {
                LoadingByteArrayOutputStream lout = (LoadingByteArrayOutputStream)currentStream;
                out.append(IOUtils.newStringFromBytes(lout.getRawBytes(), charsetName, 0, (int)limit));
            } else if (currentStream instanceof ByteArrayOutputStream) {
                byte bytes[] = ((ByteArrayOutputStream)currentStream).toByteArray();
                out.append(IOUtils.newStringFromBytes(bytes, charsetName, 0, (int)limit));
            } else {
                throw new IOException("Unknown format of currentStream");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.