Package javax.activation

Examples of javax.activation.DataSource


    }
  }

  private File getFile(){
    //get DataSource from DataHandler
    DataSource dataSource = dataHandler.getDataSource();
    if(dataSource instanceof CachedFileDataSource){
      CachedFileDataSource cds = (CachedFileDataSource)dataSource;
      //get the file object from data source.
      return cds.getFile();
    }
View Full Code Here


            if (log.isDebugEnabled()) {
                log.debug("start writeTo()");
            }
            if (attachments != null && !attachments.isEmpty()) {
                OMElement omElement = messageContext.getEnvelope().getBody().getFirstElement();
                DataSource busObject;
                try {
                    busObject = (DataSource)((DataSourceBlock)((OMSourcedElement) omElement).getDataSource()).getBusinessObject(true);
                } catch (XMLStreamException e) {
                    throw AxisFault.makeFault(e);
                }
View Full Code Here

                // Skip the SOAP part because it is never cached on file and because it may have
                // been consumed (which would cause getDataSource() to throw an exception)
                if (!contentId.equals(rootContentId)) {
                    DataHandler dh = attachments.getDataHandler(contentId);
                    if(dh != null){
                        DataSource dataSource = dh.getDataSource();
                        if(dh != null && dataSource instanceof CachedFileDataSource){
                            if (log.isDebugEnabled()) {
                                log.debug("Attachment's DataHandler uses CachedFileDataSource...");
                            }
                            File file = ((CachedFileDataSource)dataSource).getFile();
View Full Code Here

    public void write(Object obj, XMLStreamWriter writer) {
        try {
            XMLStreamReader reader = null;
            if (obj instanceof DataSource) {
                DataSource ds = (DataSource)obj;
                reader = StaxUtils.createXMLStreamReader(ds.getInputStream());
                StaxUtils.copy(reader, writer);
                reader.close();
            } else if (obj instanceof Node) {
                Node nd = (Node)obj;
                if (writer instanceof W3CDOMStreamWriter
View Full Code Here

            cache((DelegatingInputStream) body, true);
        }

        List<Attachment> atts = new ArrayList<Attachment>(attachments.getLoadedAttachments());
        for (Attachment a : atts) {
            DataSource s = a.getDataHandler().getDataSource();
            if (s instanceof AttachmentDataSource) {
                AttachmentDataSource ads = (AttachmentDataSource)s;
                if (!ads.isCached()) {
                    ads.cache();
                }
            } else if (s.getInputStream() instanceof DelegatingInputStream) {
                cache((DelegatingInputStream) s.getInputStream(), false);
            } else {
                //assume a normal stream that is already cached
            }
        }
    }
View Full Code Here

                    return new StreamSource(getInputStream(input));
                } else if (XMLStreamReader.class.isAssignableFrom(type)) {
                    return resetForStreaming(input);
                } else if (DataSource.class.isAssignableFrom(type)) {
                    final InputStream ins = getInputStream(input);
                    return new DataSource() {
                        public String getContentType() {
                            return "text/xml";
                        }
                        public InputStream getInputStream() throws IOException {
                            return ins;
View Full Code Here

            }
            att.setHeader(header.getName(), header.getValue());
        }
       
        if (quotedPrintable) {
            DataSource source = new AttachmentDataSource(ct,
                                                         new QuotedPrintableDecoderStream(stream));
            att.setDataHandler(new DataHandler(source));
        } else {
            DataSource source = new AttachmentDataSource(ct, stream);
            att.setDataHandler(new DataHandler(source));
        }
       
        return att;
    }
View Full Code Here

        }       

        // The following is just wrong. Even if the DataHandler has a stream, we should still
        // apply the threshold.
        try {
            DataSource ds = handler.getDataSource();
            if (ds instanceof FileDataSource) {
                FileDataSource fds = (FileDataSource)ds;
                File file = fds.getFile();
                if (file.length() < threshold) {
                    return null;
                }
            } else if (ds.getClass().getName().endsWith("ObjectDataSource")) {
                Object o = handler.getContent();
                if (o instanceof String
                    && ((String)o).length() < threshold) {
                    return null;
                } else if (o instanceof byte[] && ((byte[])o).length < threshold) {
View Full Code Here

        for (java.util.Iterator i = orderedAttachments.iterator();
             i.hasNext();) {
            AttachmentPart part = (AttachmentPart) i.next();
            DataHandler dh =
                    AttachmentUtils.getActivationDataHandler(part);
            DataSource ds = dh.getDataSource();

            if ((ds != null) && (ds instanceof ManagedMemoryDataSource)) {
                ((ManagedMemoryDataSource) ds).delete();
            }
        }
View Full Code Here

    }

    public Object readFrom(Class cls, Type genericType, Annotation[] annotations,
                               MediaType type, MultivaluedMap headers, InputStream is)
        throws IOException {
        DataSource ds = new InputStreamDataSource(is, type.toString());
        return DataSource.class.isAssignableFrom(cls) ? ds : new DataHandler(ds);
    }
View Full Code Here

TOP

Related Classes of javax.activation.DataSource

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.