当前位置: 首页>>代码示例>>Java>>正文


Java URLDataSource类代码示例

本文整理汇总了Java中javax.activation.URLDataSource的典型用法代码示例。如果您正苦于以下问题:Java URLDataSource类的具体用法?Java URLDataSource怎么用?Java URLDataSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


URLDataSource类属于javax.activation包,在下文中一共展示了URLDataSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDataSource

import javax.activation.URLDataSource; //导入依赖的package包/类
@JsonIgnore
public DataSource createDataSource()
{
	if (uri != null)
	{
		try
		{
			return new URLDataSource(uri.toURL());
		}
		catch (final MalformedURLException ex)
		{
			throw new AdempiereException("@[email protected] @[email protected]: " + uri, ex);
		}
	}
	else
	{
		return ByteArrayBackedDataSource.of(filename, content);
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:20,代码来源:EMailAttachment.java

示例2: testMtomSawpFile

import javax.activation.URLDataSource; //导入依赖的package包/类
@Test
@RunAsClient
public void testMtomSawpFile() throws Exception
{
   URL wsdlURL = new URL(baseURL + "?wsdl");
   QName serviceName = new QName("http://ws.jboss.org/jbws3250", "TestEndpointService");
   Endpoint port = Service.create(wsdlURL, serviceName).getPort(Endpoint.class);
   SOAPBinding binding =(SOAPBinding)((BindingProvider)port).getBinding();
   binding.setMTOMEnabled(true);
   URL url = JBossWSTestHelper.getResourceURL("jaxws/jbws3250/wsf.png");
   URLDataSource urlDatasource = new URLDataSource(url);
   javax.activation.DataHandler dh = new DataHandler(urlDatasource);
   MTOMRequest request = new MTOMRequest();
   request.setContent(dh);
   request.setId("largeSize_mtom_request");
   MTOMResponse mtomResponse = port.echo(request);
   Assert.assertEquals("Response for requestID:largeSize_mtom_request", mtomResponse.getResponse());
   byte[] responseBytes = IOUtils.convertToBytes(mtomResponse.getContent());
   Assert.assertTrue(responseBytes.length > 65536);
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:21,代码来源:JBWS3250TestCase.java

示例3: sendMessage

import javax.activation.URLDataSource; //导入依赖的package包/类
public static SOAPMessage sendMessage(String switchyard_web_service) throws Exception {
    SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();

    SOAPConnection connection = conFactory.createConnection();
    MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPMessage msg = msgFactory.createMessage();
    SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(new QName("urn:switchyard-quickstart:soap-attachment:1.0", "echoImage"));
    bodyElement.addTextNode("cid:switchyard.png");

    AttachmentPart ap = msg.createAttachmentPart();
    URL imageUrl = Classes.getResource("switchyard.png");
    ap.setDataHandler(new DataHandler(new URLDataSource(imageUrl)));
    ap.setContentId("switchyard.png");
    msg.addAttachmentPart(ap);
    msg.saveChanges();

    // SWITCHYARD-2818/CXF-6665 - CXF does not set content-type properly.
    String contentType = msg.getMimeHeaders().getHeader("Content-Type")[0];
    contentType += "; start=\"<[email protected]>\"; start-info=\"application/soap+xml\"; action=\"urn:switchyard-quickstart:soap-attachment:1.0:echoImage\"";
    msg.getMimeHeaders().setHeader("Content-Type", contentType);

    return connection.call(msg, new URL(switchyard_web_service));
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:24,代码来源:SoapAttachmentClient.java

示例4: storeContent

import javax.activation.URLDataSource; //导入依赖的package包/类
/**
 * Sends the test content file to the WebService
 */
public void storeContent() throws Exception {
    ContentStoreHttpPortService contentStoreService = new ContentStoreHttpPortService();
    ContentStoreHttpPort contentStorePort = contentStoreService.getContentStoreHttpPortSoap11();
    SOAPBinding binding = (SOAPBinding) ((BindingProvider) contentStorePort).getBinding();
    binding.setMTOMEnabled(true);

    StoreContentRequest request = objectFactory.createStoreContentRequest();
    request.setName(ClientUtil.TEST_CONTENT_NAME);
    
    DataHandler dataHandler = new DataHandler(new URLDataSource(ClientUtil.TEST_CONTENT_URL));
    request.setContent(dataHandler);
    
    StopWatch stopWatch = new StopWatch(this.getClass().getSimpleName());

    stopWatch.start("store");
    StoreContentResponse response = contentStorePort.storeContent(request);
    stopWatch.stop();
    
    System.out.println(stopWatch.prettyPrint());
}
 
开发者ID:vanioinformatika,项目名称:spring-ws-mtom-example,代码行数:24,代码来源:JaxWsClient.java

示例5: addAttachedFilePart

import javax.activation.URLDataSource; //导入依赖的package包/类
private void addAttachedFilePart(FileObject file) throws Exception
{
 // create a data source
 
 MimeBodyPart files = new MimeBodyPart();
    // create a data source
       URLDataSource fds = new URLDataSource(file.getURL());
       // get a data Handler to manipulate this file type;
       files.setDataHandler(new DataHandler(fds));
       // include the file in the data source
       files.setFileName(file.getName().getBaseName());
       // add the part with the file in the BodyPart();
       data.parts.addBodyPart(files);
       if(log.isDetailed()) log.logDetailed(toString(), Messages.getString("Mail.Log.AttachedFile",fds.getName()));
       
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:17,代码来源:Mail.java

示例6: addAttachedFilePart

import javax.activation.URLDataSource; //导入依赖的package包/类
private void addAttachedFilePart(FileObject file) throws Exception
{
 // create a data source
 
 MimeBodyPart files = new MimeBodyPart();
    // create a data source
       URLDataSource fds = new URLDataSource(file.getURL());
       // get a data Handler to manipulate this file type;
       files.setDataHandler(new DataHandler(fds));
       // include the file in the data source
       files.setFileName(file.getName().getBaseName());
       // insist on base64 to preserve line endings
       files.addHeader("Content-Transfer-Encoding", "base64");
       // add the part with the file in the BodyPart();
       data.parts.addBodyPart(files);
       if(isDetailed()) logDetailed(BaseMessages.getString(PKG, "Mail.Log.AttachedFile",fds.getName()));
       
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:19,代码来源:Mail.java

示例7: addAttachedFilePart

import javax.activation.URLDataSource; //导入依赖的package包/类
private void addAttachedFilePart( FileObject file ) throws Exception {
  // create a data source

  MimeBodyPart files = new MimeBodyPart();
  // create a data source
  URLDataSource fds = new URLDataSource( file.getURL() );
  // get a data Handler to manipulate this file type;
  files.setDataHandler( new DataHandler( fds ) );
  // include the file in the data source
  files.setFileName( file.getName().getBaseName() );
  // insist on base64 to preserve line endings
  files.addHeader( "Content-Transfer-Encoding", "base64" );
  // add the part with the file in the BodyPart();
  data.parts.addBodyPart( files );
  if ( isDetailed() ) {
    logDetailed( BaseMessages.getString( PKG, "Mail.Log.AttachedFile", fds.getName() ) );
  }

}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:20,代码来源:Mail.java

示例8: setUp

import javax.activation.URLDataSource; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    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"))));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:BodyAndHeaderConvertTest.java

示例9: storeContent

import javax.activation.URLDataSource; //导入依赖的package包/类
/**
 * Sends the test content file to the WebService
 */
public void storeContent() {
    StoreContentRequest storeContentRequest = objectFactory.createStoreContentRequest();
    storeContentRequest.setName(ClientUtil.TEST_CONTENT_NAME);
    storeContentRequest.setContent(new DataHandler(new URLDataSource(ClientUtil.TEST_CONTENT_URL)));
    stopWatch.start("store");
    getWebServiceTemplate().marshalSendAndReceive(storeContentRequest);
    stopWatch.stop();
    System.out.println(stopWatch.prettyPrint());
}
 
开发者ID:vanioinformatika,项目名称:spring-ws-mtom-example,代码行数:13,代码来源:SaajMtomClient.java

示例10: test

import javax.activation.URLDataSource; //导入依赖的package包/类
@Test
public void test() throws Exception {
    String message = client.storeContent("test", new DataHandler(new URLDataSource(TEST_CONTENT_URL)));
    System.out.println("Server message: " + message);
    assertEquals("Content successfully stored", message);
    
    DataHandler dh = client.loadContent("test");
    assertNotNull(dh);
    File tempFile = new File(System.getProperty("java.io.tmpdir"), "spring_mtom_jaxws_tmp.bin");
    tempFile.deleteOnExit();
    long size = saveContentToFile(dh, tempFile);
    assertTrue(size > 0);
    assertTrue(tempFile.length()>0);
}
 
开发者ID:vanioinformatika,项目名称:spring-boot-cxf-integration-example,代码行数:15,代码来源:SampleIntegrationApplicationTest.java

示例11: getAttachment

import javax.activation.URLDataSource; //导入依赖的package包/类
public static Attachment getAttachment(String id, Collection<Attachment> attachments) {
    if (id == null) {
        throw new DatabindingException("Cannot get attachment: null id");
    }
    int i = id.indexOf("cid:");
    if (i != -1) {
        id = id.substring(4).trim();
    }

    if (attachments == null) {
        return null;
    }

    for (Iterator<Attachment> iter = attachments.iterator(); iter.hasNext();) {
        Attachment a = iter.next();
        if (a.getId().equals(id)) {
            return a;
        }
    }

    // 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;
    }
}
 
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:29,代码来源:AttachmentUtil.java

示例12: handleRequest

import javax.activation.URLDataSource; //导入依赖的package包/类
@Override
public Parameters handleRequest(Parameters parameters, Context context) {

    context.getLogger().log("Input Function [" + context.getFunctionName() + "], Parameters [" + parameters + "]");

    try {

        // Create an empty Mime message and start populating it
        Session session = Session.getDefaultInstance(new Properties());
        MimeMessage message = new MimeMessage(session);
        message.setSubject(EMAIL_SUBJECT, "UTF-8");
        message.setFrom(new InternetAddress(System.getenv("EMAIL_FROM")));
        message.setReplyTo(new Address[] { new InternetAddress(System.getenv("EMAIL_FROM")) });
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(System.getenv("EMAIL_RECIPIENT")));

        MimeBodyPart wrap = new MimeBodyPart();
        MimeMultipart cover = new MimeMultipart("alternative");
        MimeBodyPart html = new MimeBodyPart();
        cover.addBodyPart(html);
        wrap.setContent(cover);
        MimeMultipart content = new MimeMultipart("related");
        message.setContent(content);
        content.addBodyPart(wrap);

        // Create an S3 URL reference to the snapshot that will be attached to this email
        URL attachmentURL = createSignedURL(parameters.getS3Bucket(), parameters.getS3Key());

        StringBuilder sb = new StringBuilder();
        String id = UUID.randomUUID().toString();
        sb.append("<img src=\"cid:");
        sb.append(id);
        sb.append("\" alt=\"ATTACHMENT\"/>\n");
        
        // Add the attachment as a part of the message body
        MimeBodyPart attachment = new MimeBodyPart();
        DataSource fds = new URLDataSource(attachmentURL);
        attachment.setDataHandler(new DataHandler(fds));
        
        attachment.setContentID("<" + id + ">");
        attachment.setDisposition(BodyPart.ATTACHMENT);
         
        attachment.setFileName(fds.getName());
        content.addBodyPart(attachment);

        // Pretty print the Rekognition Labels as part of the Emails HTML content
        String prettyPrintLabels = parameters.getRekognitionLabels().toString();
        prettyPrintLabels = prettyPrintLabels.replace("{", "").replace("}", "");
        prettyPrintLabels = prettyPrintLabels.replace(",", "<br>");            
        html.setContent("<html><body><h2>Uploaded Filename : " + parameters.getS3Key().replace("upload/", "") + 
                        "</h2><p><b>Detected Labels/Confidence</b><br><br>" + prettyPrintLabels + "</p>"+sb+"</body></html>", "text/html");

        // Convert the JavaMail message into a raw email request for sending via SES
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        message.writeTo(outputStream);
        RawMessage rawMessage = new RawMessage(ByteBuffer.wrap(outputStream.toByteArray()));
        SendRawEmailRequest rawEmailRequest = new SendRawEmailRequest(rawMessage);

        // Send the email using the AWS SES Service
        AmazonSimpleEmailService client = AmazonSimpleEmailServiceClientBuilder.defaultClient();
        client.sendRawEmail(rawEmailRequest);

    } catch (MessagingException | IOException e) {
        // Convert Checked Exceptions to RuntimeExceptions to ensure that
        // they get picked up by the Step Function infrastructure
        throw new AmazonServiceException("Error in ["+context.getFunctionName()+"]", e);
    }

    context.getLogger().log("Output Function [" + context.getFunctionName() + "], Parameters [" + parameters + "]");

    return parameters;
}
 
开发者ID:markwest1972,项目名称:smart-security-camera,代码行数:72,代码来源:SesSendNotificationHandler.java

示例13: standardClassDataHandler

import javax.activation.URLDataSource; //导入依赖的package包/类
public JAXBElement<DataHandler> standardClassDataHandler() {
	DataSource dataSource = new URLDataSource(getClass().getResource("spring-ws.png"));
	DataHandler dataHandler = new DataHandler(dataSource);
	return new JAXBElement<DataHandler>(NAME, DataHandler.class, dataHandler);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:StandardClasses.java

示例14: index

import javax.activation.URLDataSource; //导入依赖的package包/类
/**
 * 
 * @param u
 * @throws IOException
 */
public void index ( URL u ) throws IOException {
    try ( InputStream openStream = u.openStream() ) {
        index(new URLDataSource(u));
    }
}
 
开发者ID:mbechler,项目名称:serianalyzer,代码行数:11,代码来源:SerianalyzerInput.java

示例15: ZipIterator

import javax.activation.URLDataSource; //导入依赖的package包/类
public ZipIterator(URL url) throws Exception {
	this(new URLDataSource(url));
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:4,代码来源:ZipIterator.java


注:本文中的javax.activation.URLDataSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。