Package org.apache.cxf.io

Examples of org.apache.cxf.io.CachedWriter


        Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
    }

    @Test
    public void outWriterStreamTest() throws Exception {
        CachedWriter cWriter = new CachedWriter();
        message.setContent(Writer.class, cWriter);
        outInterceptor.handleMessage(message);
        Writer tWriter = message.getContent(Writer.class);
        IOUtils.copy(new InputStreamReader(messageIS), tWriter, IOUtils.DEFAULT_BUFFER_SIZE);
        tWriter.close();
        Document doc = StaxUtils.read(cWriter.getReader());
        Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
    }
View Full Code Here


    }

    public static Reader transform(Templates xsltTemplate, Reader inReader) {
        try {
            StreamSource beforeSource = new StreamSource(inReader);
            CachedWriter outWriter = new CachedWriter();

            Transformer trans = xsltTemplate.newTransformer();
            trans.transform(beforeSource, new StreamResult(outWriter));

            return outWriter.getReader();
        } catch (IOException e) {
            throw new Fault("GET_CACHED_INPUT_STREAM", LOG, e, e.getMessage());
        } catch (TransformerException e) {
            throw new Fault("XML_TRANSFORM", LOG, e, e.getMessage());
        }
View Full Code Here

            }
        }
    }

    protected void transformXWriter(Message message, XMLStreamWriter xWriter) {
        CachedWriter writer = new CachedWriter();
        XMLStreamWriter delegate = StaxUtils.createXMLStreamWriter(writer);
        XSLTStreamWriter wrapper = new XSLTStreamWriter(getXSLTTemplate(), writer, delegate, xWriter);
        message.setContent(XMLStreamWriter.class, wrapper);
        message.put(AbstractOutDatabindingInterceptor.DISABLE_OUTPUTSTREAM_OPTIMIZATION,
                    Boolean.TRUE);
View Full Code Here

                }
            }
        }

        protected void transformXWriter(Message message, XMLStreamWriter xWriter) {
            CachedWriter writer = new CachedWriter();
            XMLStreamWriter delegate = StaxUtils.createXMLStreamWriter(writer);
            XSLTStreamWriter wrapper = new XSLTStreamWriter(getXSLTTemplate(), writer, delegate, xWriter);
            message.setContent(XMLStreamWriter.class, wrapper);
            message.put(AbstractOutDatabindingInterceptor.DISABLE_OUTPUTSTREAM_OPTIMIZATION,
                        Boolean.TRUE);
View Full Code Here

            }
        } else {
            Reader reader = message.getContent(Reader.class);
            if (reader != null) {
                try {
                    CachedWriter writer = new CachedWriter();
                    IOUtils.copyAndCloseInput(reader, writer);
                    message.setContent(Reader.class, writer.getReader());
                   
                    if (writer.getTempFile() != null) {
                        //large thing on disk...
                        buffer.getMessage().append("\nMessage (saved to tmp file):\n");
                        buffer.getMessage().append("Filename: " + writer.getTempFile().getAbsolutePath() + "\n");
                    }
                    if (writer.size() > limit) {
                        buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
                    }
                    writer.writeCacheTo(buffer.getPayload(), limit);
                } catch (Exception e) {
                    throw new Fault(e);
                }
            }
        }
View Full Code Here

            }
        } else {
            Reader reader = message.getContent(Reader.class);
            if (reader != null) {
                try {
                    CachedWriter writer = new CachedWriter();
                    IOUtils.copyAndCloseInput(reader, writer);
                    message.setContent(Reader.class, writer.getReader());
                   
                    if (writer.getTempFile() != null) {
                        //large thing on disk...
                        buffer.getMessage().append("\nMessage (saved to tmp file):\n");
                        buffer.getMessage().append("Filename: " + writer.getTempFile().getAbsolutePath() + "\n");
                    }
                    if (writer.size() > limit) {
                        buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
                    }
                    writer.writeCacheTo(buffer.getPayload(), limit);
                } catch (Exception e) {
                    throw new Fault(e);
                }
            }
        }
View Full Code Here

        Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
    }

    @Test
    public void outXMLStreamTest() throws XMLStreamException, SAXException, IOException, ParserConfigurationException {
        CachedWriter cWriter = new CachedWriter();
        cWriter.holdTempFile();
        XMLStreamWriter xWriter = StaxUtils.createXMLStreamWriter(cWriter);
        message.setContent(XMLStreamWriter.class, xWriter);
        outInterceptor.handleMessage(message);
        XMLStreamWriter tXWriter = message.getContent(XMLStreamWriter.class);
        StaxUtils.copy(new StreamSource(messageIS), tXWriter);
        tXWriter.close();
        cWriter.releaseTempFileHold();
        Document doc = DOMUtils.readXml(cWriter.getReader());
        Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
    }
View Full Code Here

        Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
    }

    @Test
    public void outWriterStreamTest() throws IOException, SAXException, ParserConfigurationException {
        CachedWriter cWriter = new CachedWriter();
        message.setContent(Writer.class, cWriter);
        outInterceptor.handleMessage(message);
        Writer tWriter = message.getContent(Writer.class);
        IOUtils.copy(new InputStreamReader(messageIS), tWriter, IOUtils.DEFAULT_BUFFER_SIZE);
        tWriter.close();
        Document doc = DOMUtils.readXml(cWriter.getReader());
        Assert.assertTrue("Message was not transformed", checkTransformedXML(doc));
    }
View Full Code Here

TOP

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

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.