org.switchyard.Message.getAttachment()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中org.switchyard.Message.getAttachment()方法的一些代码示例,展示了Message.getAttachment()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getAttachment()方法的具体详情如下:
包路径:org.switchyard.Message
类名称:Message
方法名:getAttachment

Message.getAttachment介绍

[英]Retrieves the named attachment from the message.
[中]从邮件中检索命名附件。

代码示例

代码示例来源:origin: jboss-switchyard/components

/**
 * {@inheritDoc}
 */
@Override
public DataSource getAttachment(String name) {
  return getMessage().getAttachment(name);
}

代码示例来源:origin: org.switchyard.components/switchyard-component-camel-switchyard

/**
 * Maps a SwitchYard exchange to a Camel exchange.  Keep in mind that the camel message created
 * during mapping is *not* associate with the exchange.  You need to call setIn() or setOut() 
 * with the returned reference depending on your use case.
 * @param syExchange switchyard exchange
 * @param camelExchange camel exchange
 * @return mapped camel message
 */
public static DefaultMessage mapSwitchYardToCamel(
    org.switchyard.Exchange syExchange,
    org.apache.camel.Exchange camelExchange) {
  
  DefaultMessage camelMessage = new SwitchYardMessage();
  camelMessage.setBody(syExchange.getMessage().getContent());
  
  mapSwitchYardPropertiesToCamel(syExchange.getContext(), camelExchange, camelMessage);
  
  for (String attachmentName : syExchange.getMessage().getAttachmentMap().keySet()) {
    camelMessage.addAttachment(attachmentName, 
        new DataHandler(syExchange.getMessage().getAttachment(attachmentName)));
  }
  
  return camelMessage;
}

代码示例来源:origin: jboss-switchyard/core

@Test
public void testGetAttachmentMap() throws Exception {
  _message.addAttachment("attach1", new DummyDS("attach1", "text/xml"));
  _message.addAttachment("attach2", new DummyDS("attach1", "text/xml"));
  Map<String, DataSource> attachments = _message.getAttachmentMap();
  // make sure the attachments we added are in the map
  Assert.assertTrue(attachments.containsKey("attach1"));
  Assert.assertTrue(attachments.containsKey("attach2"));
  // make sure that modifications to the map are not reflected in the message
  // (i.e.) the returned map is not a direct reference 
  attachments.remove("attach1");
  Assert.assertNotNull(_message.getAttachment("attach1"));
}

代码示例来源:origin: org.switchyard.components/switchyard-component-bean

/**
 * {@inheritDoc}
 */
@Override
public DataSource getAttachment(String name) {
  return getMessage().getAttachment(name);
}

代码示例来源:origin: jboss-switchyard/components

new DataHandler(syExchange.getMessage().getAttachment(attachmentName)));

代码示例来源:origin: jboss-switchyard/core

@Test
public void testRemoveAttachment() throws Exception {
  _message.addAttachment("attach1", new DummyDS("attach1", "text/xml"));
  Assert.assertNotNull(_message.getAttachment("attach1"));
  _message.removeAttachment("attach1");
  Assert.assertNull(_message.getAttachment("attach1"));
  
}

代码示例来源:origin: org.switchyard.components/switchyard-component-soap

apResponse.setDataHandler(new DataHandler(message.getAttachment(name)));
apResponse.setContentId("<" + name + ">");
soapMessage.addAttachmentPart(apResponse);

代码示例来源:origin: jboss-switchyard/core

@Test
public void testAddAttachment() throws Exception {
  _message.addAttachment("attach1", new DummyDS("attach1", "text/xml"));
  Assert.assertNotNull(_message.getAttachment("attach1"));
}

代码示例来源:origin: jboss-switchyard/components

apResponse.setDataHandler(new DataHandler(message.getAttachment(name)));
apResponse.setContentId("<" + name + ">");
soapMessage.addAttachmentPart(apResponse);

相关文章