Coverage Report - org.mule.endpoint.outbound.OutboundNotificationMessageProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
OutboundNotificationMessageProcessor
0%
0/14
0%
0/6
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.endpoint.outbound;
 8  
 
 9  
 import org.mule.api.MuleEvent;
 10  
 import org.mule.api.MuleException;
 11  
 import org.mule.api.endpoint.OutboundEndpoint;
 12  
 import org.mule.api.processor.MessageProcessor;
 13  
 import org.mule.context.notification.EndpointMessageNotification;
 14  
 import org.mule.transport.AbstractConnector;
 15  
 import org.mule.util.ObjectUtils;
 16  
 
 17  
 /**
 18  
  * Publishes a {@link EndpointMessageNotification}'s when a message is sent or
 19  
  * dispatched.
 20  
  */
 21  
 
 22  
 public class OutboundNotificationMessageProcessor implements MessageProcessor
 23  
 {
 24  
 
 25  
     private OutboundEndpoint endpoint;
 26  
 
 27  
     public OutboundNotificationMessageProcessor(OutboundEndpoint endpoint)
 28  0
     {
 29  0
         this.endpoint = endpoint;
 30  0
     }
 31  
 
 32  
     public MuleEvent process(MuleEvent event) throws MuleException
 33  
     {
 34  0
         AbstractConnector connector = (AbstractConnector) endpoint.getConnector();
 35  0
         if (connector.isEnableMessageEvents())
 36  
         {
 37  0
             String component = null;
 38  0
             if (event.getFlowConstruct() != null)
 39  
             {
 40  0
                 component = event.getFlowConstruct().getName();
 41  
             }
 42  
 
 43  
             int notificationAction;
 44  0
             if (event.getEndpoint().getExchangePattern().hasResponse())
 45  
             {
 46  0
                 notificationAction = EndpointMessageNotification.MESSAGE_SENT;
 47  
             }
 48  
             else
 49  
             {
 50  0
                 notificationAction = EndpointMessageNotification.MESSAGE_DISPATCHED;
 51  
             }
 52  0
             connector.fireNotification(new EndpointMessageNotification(event.getMessage(),
 53  
                 event.getEndpoint(), component, notificationAction));
 54  
         }
 55  
 
 56  0
         return event;
 57  
     }
 58  
 
 59  
     @Override
 60  
     public String toString()
 61  
     {
 62  0
         return ObjectUtils.toString(this);
 63  
     }
 64  
 }