Examples of ByteDataSource


Examples of org.apache.cxf.attachment.ByteDataSource

            StreamSource src = (StreamSource)o;
            try {
                if (src.getInputStream() != null) {
                    ByteArrayOutputStream bos = new ByteArrayOutputStream(2048);
                    IOUtils.copy(src.getInputStream(), bos, 1024);
                    ds = new ByteDataSource(bos.toByteArray(), ct);
                } else {
                    ds = new ByteDataSource(IOUtils.toString(src.getReader()).getBytes("UTF-8"),
                                                 ct);                           
                }
            } catch (IOException e) {
                throw new Fault(e);
            }
        } else {
            ByteArrayOutputStream bwriter = new ByteArrayOutputStream();
            XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(bwriter);
            try {
                StaxUtils.copy((Source)o, writer);
                writer.flush();
                ds = new ByteDataSource(bwriter.toByteArray(), ct);
            } catch (XMLStreamException e1) {
                throw new Fault(e1);
            }
        }
        return ds;
View Full Code Here

Examples of org.apache.cxf.attachment.ByteDataSource

    @Override
    protected Attachment createAttachment(Object object, String id) {
        byte[] data = (byte[])object;

        ByteDataSource source = new ByteDataSource(data);
        source.setContentType(getContentType(object, null));
        AttachmentImpl att = new AttachmentImpl(id, new DataHandler(source));
        att.setXOP(true);

        return att;
    }
View Full Code Here

Examples of org.apache.cxf.attachment.ByteDataSource

            dh = getHandlerForObject(att.getObject(), att.getObject().getClass(),
                                     att.getObject().getClass(), new Annotation[]{},
                                     att.getContentType().toString(), id);
            return new Attachment(att.getContentId(), dh, att.getHeaders());
        } else if (byte[].class.isAssignableFrom(obj.getClass())) {
            ByteDataSource source = new ByteDataSource((byte[])obj);
            source.setContentType(mimeType);
            dh = new DataHandler(source);
        } else {
            dh = getHandlerForObject(obj, cls, genericType, anns, mimeType, id);
        }
        String contentId = getContentId(anns, id);
View Full Code Here

Examples of org.apache.cxf.attachment.ByteDataSource

                                            Object obj,
                                            Class<?> cls,
                                            Type genericType,
                                            Annotation[] anns,
                                            MediaType contentType) {
            super(new ByteDataSource("1".getBytes()));
            this.writer = writer;
            this.obj = obj;
            this.cls = cls;
            this.genericType = genericType;
            this.anns = anns;
View Full Code Here

Examples of org.apache.cxf.attachment.ByteDataSource

        Exchange exchange = new ExchangeImpl();
        Message inMessage = new MessageImpl();
       
        Collection<Attachment> attachments = new LinkedList<Attachment>();

        DataSource source = new ByteDataSource(new byte[0], "text/xml");
       
        DataHandler handler1 = new DataHandler(source);
        attachments.add(new AttachmentImpl("part1", handler1));
        DataHandler handler2 = new DataHandler(source);
        attachments.add(new AttachmentImpl("part2", handler2));
View Full Code Here

Examples of org.apache.cxf.attachment.ByteDataSource

            dh = getHandlerForObject(att.getObject(),
                                     att.getObject().getClass(), new Annotation[]{},
                                     att.getContentType().toString(), id);
            return new Attachment(att.getContentId(), dh, att.getHeaders());
        } else if (byte[].class.isAssignableFrom(obj.getClass())) {
            ByteDataSource source = new ByteDataSource((byte[])obj);
            source.setContentType(mimeType);
            dh = new DataHandler(source);
        } else {
            dh = getHandlerForObject(obj, cls, genericType, anns, mimeType, id);
        }
        String contentId = getContentId(anns, id);
View Full Code Here

Examples of org.apache.cxf.attachment.ByteDataSource

                                            T obj,
                                            Class<T> cls,
                                            Type genericType,
                                            Annotation[] anns,
                                            MediaType contentType) {
            super(new ByteDataSource("1".getBytes()));
            this.writer = writer;
            this.obj = obj;
            this.cls = cls;
            this.genericType = genericType;
            this.anns = anns;
View Full Code Here

Examples of org.apache.cxf.attachment.ByteDataSource

            dh = getHandlerForObject(att.getObject(), att.getObject().getClass(),
                                     att.getObject().getClass(), new Annotation[]{},
                                     att.getContentType().toString(), id);
            return new Attachment(att.getContentId(), dh, att.getHeaders());
        } else if (byte[].class.isAssignableFrom(obj.getClass())) {
            ByteDataSource source = new ByteDataSource((byte[])obj);
            source.setContentType(mimeType);
            dh = new DataHandler(source);
        } else {
            dh = getHandlerForObject(obj, cls, genericType, anns, mimeType, id);
        }
        String contentId = getContentId(anns, id);
View Full Code Here

Examples of org.apache.cxf.attachment.ByteDataSource

                                            Object obj,
                                            Class<?> cls,
                                            Type genericType,
                                            Annotation[] anns,
                                            MediaType contentType) {
            super(new ByteDataSource("1".getBytes()));
            this.writer = writer;
            this.obj = obj;
            this.cls = cls;
            this.genericType = genericType;
            this.anns = anns;
View Full Code Here

Examples of org.apache.cxf.attachment.ByteDataSource

            dh = getHandlerForObject(att.getObject(), att.getObject().getClass(),
                                     att.getObject().getClass(), new Annotation[]{},
                                     att.getContentType().toString(), id);
            return new Attachment(att.getContentId(), dh, att.getHeaders());
        } else if (byte[].class.isAssignableFrom(obj.getClass())) {
            ByteDataSource source = new ByteDataSource((byte[])obj);
            source.setContentType(mimeType);
            dh = new DataHandler(source);
        } else {
            dh = getHandlerForObject(obj, cls, genericType, anns, mimeType, id);
        }
        String contentId = getContentId(anns, id);
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.