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

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

本文整理了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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public DataSource getAttachment(String name) {
  6. return getMessage().getAttachment(name);
  7. }

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

  1. /**
  2. * Maps a SwitchYard exchange to a Camel exchange. Keep in mind that the camel message created
  3. * during mapping is *not* associate with the exchange. You need to call setIn() or setOut()
  4. * with the returned reference depending on your use case.
  5. * @param syExchange switchyard exchange
  6. * @param camelExchange camel exchange
  7. * @return mapped camel message
  8. */
  9. public static DefaultMessage mapSwitchYardToCamel(
  10. org.switchyard.Exchange syExchange,
  11. org.apache.camel.Exchange camelExchange) {
  12. DefaultMessage camelMessage = new SwitchYardMessage();
  13. camelMessage.setBody(syExchange.getMessage().getContent());
  14. mapSwitchYardPropertiesToCamel(syExchange.getContext(), camelExchange, camelMessage);
  15. for (String attachmentName : syExchange.getMessage().getAttachmentMap().keySet()) {
  16. camelMessage.addAttachment(attachmentName,
  17. new DataHandler(syExchange.getMessage().getAttachment(attachmentName)));
  18. }
  19. return camelMessage;
  20. }

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

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

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public DataSource getAttachment(String name) {
  6. return getMessage().getAttachment(name);
  7. }

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

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

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

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

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

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

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

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

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

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

相关文章