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

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

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

/**
 * {@inheritDoc}
 */
@Override
public Map<String, DataSource> getAttachmentMap() {
  return getMessage().getAttachmentMap();
}

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

/**
 * {@inheritDoc}
 */
@Override
public Map<String, DataSource> getAttachmentMap() {
  return getMessage().getAttachmentMap();
}

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

/**
   * {@inheritDoc}
   */
  @Override
  public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception {
    Message sourceMessage = exchange.getMessage();
    getContextMapper().mapTo(exchange.getContext(), target);

    org.apache.camel.Message targetMessage = target.getMessage();

    if (!sourceMessage.getAttachmentMap().isEmpty()) {
      for (Entry<String, DataSource> entry : sourceMessage.getAttachmentMap().entrySet()) {
        targetMessage.addAttachment(entry.getKey(), new DataHandler(entry.getValue()));
      }
    }

    ServiceOperation operation = exchange.getContract().getProviderOperation();
    target.getMessage().getExchange().setProperty(OPERATION_NAME, operation.getName());
    target.getMessage().getExchange().setProperty(FAULT_TYPE, operation.getFaultType());
    target.getMessage().getExchange().setProperty(SERVICE_NAME, exchange.getProvider().getName());

    targetMessage.setBody(sourceMessage.getContent());
    return target;
  }
}

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

/**
   * {@inheritDoc}
   */
  @Override
  public CamelBindingData decompose(Exchange exchange, CamelBindingData target) throws Exception {
    Message sourceMessage = exchange.getMessage();
    getContextMapper().mapTo(exchange.getContext(), target);

    org.apache.camel.Message targetMessage = target.getMessage();

    if (!sourceMessage.getAttachmentMap().isEmpty()) {
      for (Entry<String, DataSource> entry : sourceMessage.getAttachmentMap().entrySet()) {
        targetMessage.addAttachment(entry.getKey(), new DataHandler(entry.getValue()));
      }
    }

    ServiceOperation operation = exchange.getContract().getProviderOperation();
    target.getMessage().getExchange().setProperty(OPERATION_NAME, operation.getName());
    target.getMessage().getExchange().setProperty(FAULT_TYPE, operation.getFaultType());
    target.getMessage().getExchange().setProperty(SERVICE_NAME, exchange.getProvider().getName());

    targetMessage.setBody(sourceMessage.getContent());
    return target;
  }
}

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

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

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

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

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

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

相关文章