Coverage Report - org.mule.endpoint.inbound.InboundEndpointPropertyMessageProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
InboundEndpointPropertyMessageProcessor
0%
0/9
0%
0/2
0
 
 1  
 /*
 2  
  * $Id: InboundEndpointPropertyMessageProcessor.java 19484 2010-09-09 12:08:21Z tcarlson $
 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.inbound;
 12  
 
 13  
 import org.mule.api.MuleEvent;
 14  
 import org.mule.api.MuleException;
 15  
 import org.mule.api.config.MuleProperties;
 16  
 import org.mule.api.endpoint.InboundEndpoint;
 17  
 import org.mule.api.processor.MessageProcessor;
 18  
 import org.mule.api.transport.PropertyScope;
 19  
 import org.mule.util.ObjectUtils;
 20  
 import org.mule.util.StringUtils;
 21  
 
 22  
 
 23  
 /**
 24  
  * Sets the inbound endpoint uri on as a property of the message using the following
 25  
  * key: {@link MuleProperties#MULE_ORIGINATING_ENDPOINT_PROPERTY}.
 26  
  */
 27  
 public class InboundEndpointPropertyMessageProcessor implements MessageProcessor
 28  
 {
 29  
     private InboundEndpoint endpoint;
 30  
 
 31  
     public InboundEndpointPropertyMessageProcessor(InboundEndpoint endpoint)
 32  0
     {
 33  0
         this.endpoint = endpoint;
 34  0
     }
 35  
 
 36  
     public MuleEvent process(MuleEvent event) throws MuleException
 37  
     {
 38  
         // If the endpoint has a logical name, use it, otherwise use the URI.
 39  0
         String inboundEndpoint = endpoint.getName();
 40  
 
 41  0
         if (StringUtils.isBlank(inboundEndpoint))
 42  
         {
 43  
             // URI
 44  0
             inboundEndpoint = endpoint.getEndpointURI().getUri().toString();
 45  
         }
 46  0
         event.getMessage().setProperty(MuleProperties.MULE_ORIGINATING_ENDPOINT_PROPERTY, inboundEndpoint, PropertyScope.INBOUND);
 47  0
         return event;
 48  
     }
 49  
 
 50  
     @Override
 51  
     public String toString()
 52  
     {
 53  0
         return ObjectUtils.toString(this);
 54  
     }
 55  
 }