Package javax.activation

Examples of javax.activation.FileDataSource


        //javax.activation.MimetypesFileTypeMap map= (javax.activation.MimetypesFileTypeMap)javax.activation.MimetypesFileTypeMap.getDefaultFileTypeMap();
        //map.addMimeTypes("application/x-org-apache-axis-wsdd wsdd");


        //Create the data for the attached file.
        DataHandler dhSource = new DataHandler( new FileDataSource( filename ));

        Service  service = new Service();

        Call     call    = (Call) service.createCall();
View Full Code Here


                }
                catch ( java.io.IOException e) {
                    System.err.println("Couldn't get file \"" + fname + "\" skipping...");
                    continue;
                }
                retList.add( new DataHandler( new FileDataSource( fname )));
            }
        }
        if (!retList.isEmpty()) {
            ret = new DataHandler[ retList.size()];
            ret = (DataHandler[]) retList.toArray(ret);
View Full Code Here

                }
                catch ( java.io.IOException e) {
                    System.err.println("Couldn't get file \"" + fname + "\" skipping...");
                    continue;
                }
                retList.add( new DataHandler( new FileDataSource( fname )));
            }
        }
        if (!retList.isEmpty()) {
            ret = new DataHandler[ retList.size()];
            ret = (DataHandler[]) retList.toArray(ret);
View Full Code Here

 
  public void testWriteAndReadNonSoapMessageWithAttachments() throws Exception {
    SoapMarshaler marshaler = new SoapMarshaler(false);
    SoapMessage msg = new SoapMessage();
    msg.setSource(new StreamSource(getClass().getResourceAsStream("soap.xml")));
    msg.addAttachment("servicemix.jpg", new DataHandler(new FileDataSource(new File(new URI(getClass().getResource("servicemix.jpg").toString())))));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SoapWriter writer = marshaler.createWriter(msg);
    writer.write(baos);
    log.info(baos.toString());
   
View Full Code Here

    }
   
  public void testWriteAndReadSoapMessageWithAttachments() throws Exception {
    SoapMarshaler marshaler = new SoapMarshaler(true);
    SoapMessage msg = marshaler.createReader().read(getClass().getResourceAsStream("soap.xml"));
    msg.addAttachment("servicemix.jpg", new DataHandler(new FileDataSource(new File(new URI(getClass().getResource("servicemix.jpg").toString())))));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SoapWriter writer = marshaler.createWriter(msg);
    writer.write(baos);
    log.info(baos.toString());
   
View Full Code Here

        ap.setContent("some attachment text...", "text/plain");
        msg.addAttachmentPart(ap);

        String jpgfilename = "docs/axis.jpg";
        File myfile = new File(jpgfilename);
        FileDataSource fds = new FileDataSource(myfile);
        DataHandler dh = new DataHandler(fds);
        AttachmentPart ap2 = msg.createAttachmentPart(dh);
        ap2.setContentType("image/jpg");
        msg.addAttachmentPart(ap2);
View Full Code Here

    File file = new File(SOURCE_IMAGE_FILE);
    assertTrue(file.exists());

    sourceLength = file.length();

    DataSource dataSource = new FileDataSource(file);
    assertNotNull(dataSource);
    DataHandler dataHandler = new DataHandler(dataSource);

    OMText textData = fac.createOMText(dataHandler, true);
    attachElem.addChild(textData);
View Full Code Here

                if (!file.exists() || !file.canRead()) {
                    throw new BuildException("File \"" + file.getAbsolutePath()
                         + "\" does not exist or is not "
                         + "readable.");
                }
                FileDataSource fileData = new FileDataSource(file);
                DataHandler fileDataHandler = new DataHandler(fileData);

                body.setDataHandler(fileDataHandler);
                body.setFileName(file.getName());
                attachments.addBodyPart(body);
View Full Code Here

    }

    public static void main(String[] args) throws Exception {
        TextFileDataSource textFileDataSource = new TextFileDataSource(
            //    new File("/tmp/test.txt"));
            new FileDataSource("/home/asankha/code/synapse/repository/conf/sample/resources/transform/message.xml"));

        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMSourcedElementImpl element =
            new OMSourcedElementImpl(
                BaseConstants.DEFAULT_TEXT_WRAPPER, fac, textFileDataSource);
View Full Code Here

        if (traceOn && trace.isTraceEnabled()) {
            trace.trace("Wrapping text transformation result from : " + file);
        }

        if (file != null) {
            TextFileDataSource txtFileDS = new TextFileDataSource(new FileDataSource(file));
            wrapper = new OMSourcedElementImpl(BaseConstants.DEFAULT_TEXT_WRAPPER, fac, txtFileDS);
        }

        return wrapper;
    }
View Full Code Here

TOP

Related Classes of javax.activation.FileDataSource

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.