コード例 #1
0
  /** {@inheritDoc} */
  @Override
  public void mapTo(Context context, JMSBindingData target) throws Exception {
    super.mapTo(context, target);

    Message message = target.getMessage();
    for (Property property : context.getProperties()) {
      String name = property.getName();

      if (matches(name)) {
        Object value = property.getValue();
        if (value == null) {
          continue;
        }

        try {
          // process JMS headers
          if (name.equals(HEADER_JMS_DESTINATION)) {
            message.setJMSDestination(Destination.class.cast(value));
          } else if (name.equals(HEADER_JMS_DELIVERY_MODE)) {
            message.setJMSDeliveryMode(Integer.parseInt(value.toString()));
          } else if (name.equals(HEADER_JMS_EXPIRATION)) {
            message.setJMSExpiration(Long.parseLong(value.toString()));
          } else if (name.equals(HEADER_JMS_PRIORITY)) {
            message.setJMSPriority(Integer.parseInt(value.toString()));
          } else if (name.equals(HEADER_JMS_MESSAGE_ID)) {
            message.setJMSMessageID(value.toString());
          } else if (name.equals(HEADER_JMS_TIMESTAMP)) {
            message.setJMSTimestamp(Long.parseLong(value.toString()));
          } else if (name.equals(HEADER_JMS_CORRELATION_ID)) {
            message.setJMSCorrelationID(value.toString());
          } else if (name.equals(HEADER_JMS_REPLY_TO)) {
            message.setJMSReplyTo(Destination.class.cast(value));
          } else if (name.equals(HEADER_JMS_TYPE)) {
            message.setJMSType(value.toString());
          } else if (name.equals(HEADER_JMS_REDELIVERED)) {
            message.setJMSRedelivered(Boolean.parseBoolean(value.toString()));

            // process JMS properties
          } else {
            message.setObjectProperty(name, value);
          }
        } catch (Throwable t) {
          continue;
        }
      } else if (matches(name, getIncludeRegexes(), new ArrayList<Pattern>())) {
        Object value = property.getValue();
        if (value == null) {
          continue;
        }
        message.setObjectProperty(name, value);
      }
    }
  }
コード例 #2
0
 @Override
 public void process(Exchange exchange) throws Exception {
   CamelExchange ex = new CamelExchange(exchange);
   if (ex.getState() != ExchangeState.FAULT) {
     Exception exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
     notifyListeners(exchange.getContext(), ex, exception);
     Throwable content = detectHandlerException(exception);
     org.switchyard.Property rollbackOnFaultProperty =
         ex.getContext().getProperty(org.switchyard.Exchange.ROLLBACK_ON_FAULT);
     if (rollbackOnFaultProperty == null || rollbackOnFaultProperty.getValue() == null) {
       ex.getContext()
           .setProperty(org.switchyard.Exchange.ROLLBACK_ON_FAULT, Boolean.TRUE, Scope.EXCHANGE);
     }
     ex.sendFault(ex.createMessage().setContent(content));
     ExchangeHelper.setFailureHandled(exchange);
   }
 }
コード例 #3
0
 /** {@inheritDoc} */
 @Override
 public void mapTo(Context context, ClientMessage target) throws Exception {
   for (Property property : context.getProperties(EXCHANGE)) {
     String name = property.getName();
     if (matches(name)) {
       Object value = property.getValue();
       if (value != null) {
         try {
           // Context EXCHANGE properties -> HornetQ ClientMessage properties
           target.putObjectProperty(name, value);
         } catch (PropertyConversionException pce) {
           // ignore and keep going (here just to keep checkstyle happy)
           pce.getMessage();
         }
       }
     }
   }
 }
コード例 #4
0
 /** {@inheritDoc} */
 @Override
 public void mapTo(Context context, JMSBindingData target) throws Exception {
   Message message = target.getMessage();
   for (Property property : context.getProperties(Scope.EXCHANGE)) {
     String name = property.getName();
     if (matches(name)) {
       Object value = property.getValue();
       if (value != null) {
         try {
           // Context EXCHANGE properties -> JMS Message properties
           message.setObjectProperty(name, value);
         } catch (Throwable t) {
           // ignore and keep going (here just to keep checkstyle happy)
           t.getMessage();
         }
       }
     }
   }
 }
コード例 #5
0
 @Override
 public void mapTo(Context context, SOAPBindingData target) throws Exception {
   SOAPMessage soapMessage = target.getSOAPMessage();
   MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
   SOAPHeader soapHeader = soapMessage.getSOAPHeader();
   for (Property property : context.getProperties(Scope.IN)) {
     Object value = property.getValue();
     if (value != null) {
       String name = property.getName();
       QName qname = XMLHelper.createQName(name);
       boolean qualifiedForSoapHeader = Strings.trimToNull(qname.getNamespaceURI()) != null;
       if (qualifiedForSoapHeader && matches(qname)) {
         if (value instanceof Node) {
           Node domNode = soapHeader.getOwnerDocument().importNode((Node) value, true);
           soapHeader.appendChild(domNode);
         } else if (value instanceof Configuration) {
           Element configElement = new ElementPuller().pull(new StringReader(value.toString()));
           Node configNode = soapHeader.getOwnerDocument().importNode(configElement, true);
           soapHeader.appendChild(configNode);
         } else {
           String v = value.toString();
           if (SOAPHeadersType.XML.equals(getSOAPHeadersType())) {
             try {
               Element xmlElement = new ElementPuller().pull(new StringReader(v));
               Node xmlNode = soapHeader.getOwnerDocument().importNode(xmlElement, true);
               soapHeader.appendChild(xmlNode);
             } catch (Throwable t) {
               soapHeader.addChildElement(qname).setValue(v);
             }
           } else {
             soapHeader.addChildElement(qname).setValue(v);
           }
         }
       } else {
         if (matches(name)) {
           mimeHeaders.addHeader(name, String.valueOf(value));
         }
       }
     }
   }
 }
コード例 #6
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);
          }
        }
      }
    }
  }