View Javadoc

1   /*
2    * $Id: OutboundRootMessageIdPropertyMessageProcessor.java 23247 2011-10-24 17:16:56Z mike.schilling $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.endpoint.outbound;
12  
13  import org.mule.OptimizedRequestContext;
14  import org.mule.api.MuleEvent;
15  import org.mule.api.MuleException;
16  import org.mule.api.MuleMessage;
17  import org.mule.api.config.MuleProperties;
18  import org.mule.api.endpoint.OutboundEndpoint;
19  import org.mule.api.processor.MessageProcessor;
20  import org.mule.util.ObjectUtils;
21  
22  import java.util.Iterator;
23  
24  /**
25   * Sets the outbound root message id on as a property of the message using the following key:
26   * {@link org.mule.api.config.MuleProperties#MULE_ROOT_MESSAGE_ID_PROPERTY}.
27   */
28  public class OutboundRootMessageIdPropertyMessageProcessor implements MessageProcessor
29  {
30      public MuleEvent process(MuleEvent event) throws MuleException
31      {
32          event.getMessage().setOutboundProperty(MuleProperties.MULE_ROOT_MESSAGE_ID_PROPERTY,
33              event.getMessage().getMessageRootId());
34          return event;
35      }
36  
37      @Override
38      public String toString()
39      {
40          return ObjectUtils.toString(this);
41      }
42  }