Package javax.activation

Examples of javax.activation.URLDataSource


        DataSource ds;
        try {
            File f = new File(getClass().getResource("/log4j.properties").toURI());
            ds = new FileDataSource(f);
        } catch (URISyntaxException ex) {
            ds = new URLDataSource(getClass().getResource("/log4j.properties"));
        }
        DataHandler dh = new DataHandler(ds);

        BodyPart attachmentBodyPart;
        // Create another body part
View Full Code Here


        exchange = new DefaultExchange(new DefaultCamelContext());
        exchange.setProperty("foo", 1234);
        Message message = exchange.getIn();
        message.setBody("<hello>world!</hello>");
        message.setHeader("bar", 567);
        message.addAttachment("att", new DataHandler(new URLDataSource(new URL("http://camel.apache.org/message.html"))));
    }
View Full Code Here

    entry5.addLink("/2003/12/13/atom03/4");
    entry5.setId("urn:uuid:1225c695-cfb8-4ebb-aaaa-80cb323feb5c");
    entry5.setUpdated(new Date());
    entry5.setSummary("A simple Base64 encoded binary image");
    URL url = Create.class.getResource("/atom-logo75px.gif");
    entry5.setContent(new DataHandler(new URLDataSource(url)), "image/gif");
   
    // XML content
    Entry entry6 = feed.addEntry();
    entry6.setTitle("re: Atom-Powered Robots Run Amok");
    entry6.addLink("/2003/12/13/atom03/5");
View Full Code Here

        exchange = new DefaultExchange(new DefaultCamelContext());
        exchange.setProperty("foo", 1234);
        Message message = exchange.getIn();
        message.setBody("<hello>world!</hello>");
        message.setHeader("bar", 567);
        message.addAttachment("att", new DataHandler(new URLDataSource(new URL("http://camel.apache.org/message.html"))));
    }
View Full Code Here

      try
      {
         if (getValue() instanceof URL)
         {
            URL url = (URL) getValue();
            ds = new URLDataSource(url);
         }
         else if (getValue() instanceof File)
         {
            File file = (File) getValue();
            ds = new FileDataSource(file);
         }
         else if (getValue() instanceof String)
         {
            String string = (String) getValue();
            ds = new URLDataSource( FacesResources.getResource( string, context.getExternalContext() ) );
         }
         else if (getValue() instanceof InputStream)
         {
            InputStream is = (InputStream) getValue();
            ds = new ByteArrayDataSource(is, getContentType());
View Full Code Here

            }
        }

        // Try loading the URL remotely
        try {
            URLDataSource source = new URLDataSource(new URL(id));
            return new AttachmentImpl(id, new DataHandler(source));
        } catch (MalformedURLException e) {
            return null;
        }
    }
View Full Code Here

                }
            } else if (dh == null) {
                throw new Fault(new org.apache.cxf.common.i18n.Message("ATTACHMENT_NOT_SUPPORTED",
                                                                       LOG, o.getClass()));
            } else if (dh.getDataSource() instanceof URLDataSource) {
                URLDataSource ds = (URLDataSource)dh.getDataSource();
                dh = new DataHandler(ds.getURL());
                ct = ds.getContentType();
            }
           
            AttachmentImpl att = new AttachmentImpl(id);
            att.setDataHandler(dh);
            att.setHeader("Content-Type", ct);
View Full Code Here

        entry5.addLink("/2003/12/13/atom03/4");
        entry5.setId("urn:uuid:1225c695-cfb8-4ebb-aaaa-80cb323feb5c");
        entry5.setUpdated(new Date());
        entry5.setSummary("A simple Base64 encoded binary image");
        URL url = Create.class.getResource("/atom-logo75px.gif");
        entry5.setContent(new DataHandler(new URLDataSource(url)), "image/gif");

        // XML content
        Entry entry6 = feed.addEntry();
        entry6.setTitle("re: Atom-Powered Robots Run Amok");
        entry6.addLink("/2003/12/13/atom03/5");
View Full Code Here

        if (src == null) {
            dh =
                (DataHandler)DataHandlerUtils
                    .getDataHandlerFromText(getText(), (type != null) ? type.toString() : null);
        } else {
            dh = new DataHandler(new URLDataSource(src));
        }
        return dh;
    }
View Full Code Here

            return loadDataSource(contentId, atts);
        } else if (contentId.indexOf("://") == -1) {
            return loadDataSource(contentId, atts);
        } else {
            try {
                return new URLDataSource(new URL(contentId));
            } catch (MalformedURLException e) {
                throw new Fault(e);
            }
        }
       
View Full Code Here

TOP

Related Classes of javax.activation.URLDataSource

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.