예제 #1
0
  /** {@inheritDoc} */
  @Override
  public void mapTo(Context context, CamelBindingData target) throws Exception {
    Message message = target.getMessage();
    Exchange exchange = message.getExchange();

    for (Property property : context.getProperties(Scope.MESSAGE)) {
      String name = property.getName();
      if (matches(name) && !name.startsWith("org.switchyard.bus.camel")) {
        Object value = property.getValue();
        if (value != null) {
          message.setHeader(name, value);
        }
      }
    }
    if (exchange != null) {
      for (Property property : context.getProperties(Scope.EXCHANGE)) {
        String name = property.getName();
        if (matches(name) && !name.startsWith("org.switchyard.bus.camel")) {
          Object value = property.getValue();
          if (value != null) {
            exchange.setProperty(name, value);
          }
        }
      }
    }
  }
예제 #2
0
  /** {@inheritDoc} */
  @Override
  public void mapFrom(CamelBindingData source, Context context) throws Exception {
    Message message = source.getMessage();
    Exchange exchange = message.getExchange();

    for (Map.Entry<String, Object> header : message.getHeaders().entrySet()) {
      String name = header.getKey();
      if (matches(name) && !name.startsWith("org.switchyard.bus.camel")) {
        Object value = header.getValue();
        if (value != null) {
          context.setProperty(name, value, Scope.MESSAGE).addLabels(getCamelLabels());
        }
      }
    }
    if (exchange != null) {
      for (Map.Entry<String, Object> property : exchange.getProperties().entrySet()) {
        String name = property.getKey();
        if (matches(name) && !name.startsWith("org.switchyard.bus.camel")) {
          Object value = property.getValue();
          if (value != null) {
            context.setProperty(name, value, Scope.EXCHANGE).addLabels(getCamelLabels());
          }
        }
      }
    }
  }