Package org.apache.cxf.io

Examples of org.apache.cxf.io.CachedOutputStream


    }

    public Object read(QName name, Node input, Class type) {
        if (SAXSource.class.isAssignableFrom(type)) {
            try {
                CachedOutputStream out = new CachedOutputStream();
                DOMUtils.writeXml(input, out);
               
                return new SAXSource(new InputSource(out.getInputStream()));
            } catch (IOException e) {
                throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG), e);
            } catch (TransformerException e) {
                throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG), e);
            }
        } else if (StreamSource.class.isAssignableFrom(type)) {
            try {
                CachedOutputStream out = new CachedOutputStream();               
                DOMUtils.writeXml(input, out);
                InputStream is = out.getInputStream();
                out.close();
               
                return new StreamSource(is);
            } catch (IOException e) {
                throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG), e);
            } catch (TransformerException e) {
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

            buffer.getHeader().append(headers);
        }
           
        InputStream is = message.getContent(InputStream.class);
        if (is != null) {
            CachedOutputStream bos = new CachedOutputStream();
            try {
                IOUtils.copy(is, bos);

                bos.flush();
                is.close();

                message.setContent(InputStream.class, bos.getInputStream());
                if (bos.getTempFile() != null) {
                    //large thing on disk...
                    buffer.getMessage().append("\nMessage (saved to tmp file):\n");
                    buffer.getMessage().append("Filename: " + bos.getTempFile().getAbsolutePath() + "\n");
                }
                if (bos.size() > limit) {
                    buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
                }
                bos.writeCacheTo(buffer.getPayload(), limit);
                   
                bos.close();
            } catch (IOException e) {
                throw new Fault(e);
            }
        }
View Full Code Here

        this.namespaceUri = nsUri;
    }

    public Element getElement() {
        if (element == null && getSchema() != null) {
            CachedOutputStream cout = new CachedOutputStream();
            getSchema().write(cout);
            Document sdoc = null;
            try {
                sdoc = XMLUtils.parse(cout.getInputStream());
                cout.close();
            } catch (Exception e1) {
                return null;
            }
           
            Element e = sdoc.getDocumentElement();
View Full Code Here

        if (enabled) {
            boolean streamingOn = InjectionUtils.invokeBooleanGetter(w, "getEnableStreaming");
            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

        }
    }
   
   
    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

            buffer.getAddress().append(uri);
        }
           
        InputStream is = message.getContent(InputStream.class);
        if (is != null) {
            CachedOutputStream bos = new CachedOutputStream();
            try {
                IOUtils.copy(is, bos);

                bos.flush();
                is.close();

                message.setContent(InputStream.class, bos.getInputStream());
                if (bos.getTempFile() != null) {
                    //large thing on disk...
                    buffer.getMessage().append("\nMessage (saved to tmp file):\n");
                    buffer.getMessage().append("Filename: " + bos.getTempFile().getAbsolutePath() + "\n");
                }
                if (bos.size() > limit) {
                    buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
                }
                writePayload(buffer.getPayload(), bos, encoding, ct);
                   
                bos.close();
            } catch (Exception e) {
                throw new Fault(e);
            }
        }
        log(buffer.toString());
View Full Code Here

        if (isStackOverFlow) {
            throw new StackOverflowError();
        } else {
            InputStream is = message.getContent(InputStream.class);
            if (is != null) {
                CachedOutputStream bos = new CachedOutputStream();
                try {
                    is = getClass().getClassLoader().getResourceAsStream(
                        "org/apache/cxf/systest/dispatch/resources/GreetMeDocLiteralRespBreakThreshold.xml");
                    IOUtils.copy(is, bos);
                    bos.flush();
                    is.close();
                    message.setContent(InputStream.class, bos.getInputStream());
                    bos.close();
                    message.setContent(InputStream.class, bos.getInputStream());
                } catch (IOException e) {
                    throw new Fault(e);
                }
            }
        }
View Full Code Here

            post.releaseConnection();
        }
    }
   
    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

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.