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

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

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

Message.getAttachmentMap介绍

[英]Returns a map containing all attachments to this message. The returned map is not a live reference to the underlying attachment map in the Message so changes to the returned map will not be reflected in the Message instance.
[中]返回包含此邮件所有附件的映射。返回的映射不是对消息中底层附件映射的实时引用,因此对返回映射的更改不会反映在消息实例中。

代码示例

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public Map<String, DataSource> getAttachmentMap() {
  6. return getMessage().getAttachmentMap();
  7. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public Map<String, DataSource> getAttachmentMap() {
  6. return getMessage().getAttachmentMap();
  7. }

代码示例来源: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-common-camel

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception {
  6. Message sourceMessage = exchange.getMessage();
  7. getContextMapper().mapTo(exchange.getContext(), target);
  8. org.apache.camel.Message targetMessage = target.getMessage();
  9. if (!sourceMessage.getAttachmentMap().isEmpty()) {
  10. for (Entry<String, DataSource> entry : sourceMessage.getAttachmentMap().entrySet()) {
  11. targetMessage.addAttachment(entry.getKey(), new DataHandler(entry.getValue()));
  12. }
  13. }
  14. ServiceOperation operation = exchange.getContract().getProviderOperation();
  15. target.getMessage().getExchange().setProperty(OPERATION_NAME, operation.getName());
  16. target.getMessage().getExchange().setProperty(FAULT_TYPE, operation.getFaultType());
  17. target.getMessage().getExchange().setProperty(SERVICE_NAME, exchange.getProvider().getName());
  18. targetMessage.setBody(sourceMessage.getContent());
  19. return target;
  20. }
  21. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception {
  6. Message sourceMessage = exchange.getMessage();
  7. getContextMapper().mapTo(exchange.getContext(), target);
  8. org.apache.camel.Message targetMessage = target.getMessage();
  9. if (!sourceMessage.getAttachmentMap().isEmpty()) {
  10. for (Entry<String, DataSource> entry : sourceMessage.getAttachmentMap().entrySet()) {
  11. targetMessage.addAttachment(entry.getKey(), new DataHandler(entry.getValue()));
  12. }
  13. }
  14. ServiceOperation operation = exchange.getContract().getProviderOperation();
  15. target.getMessage().getExchange().setProperty(OPERATION_NAME, operation.getName());
  16. target.getMessage().getExchange().setProperty(FAULT_TYPE, operation.getFaultType());
  17. target.getMessage().getExchange().setProperty(SERVICE_NAME, exchange.getProvider().getName());
  18. targetMessage.setBody(sourceMessage.getContent());
  19. return target;
  20. }
  21. }

代码示例来源: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/components

  1. for (String name : message.getAttachmentMap().keySet()) {
  2. AttachmentPart apResponse = soapMessage.createAttachmentPart();
  3. apResponse.setDataHandler(new DataHandler(message.getAttachment(name)));

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

  1. for (String name : message.getAttachmentMap().keySet()) {
  2. AttachmentPart apResponse = soapMessage.createAttachmentPart();
  3. apResponse.setDataHandler(new DataHandler(message.getAttachment(name)));

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

  1. for (String attachmentName : syExchange.getMessage().getAttachmentMap().keySet()) {
  2. camelMessage.addAttachment(attachmentName,
  3. new DataHandler(syExchange.getMessage().getAttachment(attachmentName)));

相关文章