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  
  * $Id: OutboundNotificationMessageProcessor.java 20221 2010-11-17 17:49:45Z aperepel $
 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.api.MuleEvent;
 14  
 import org.mule.api.MuleException;
 15  
 import org.mule.api.endpoint.OutboundEndpoint;
 16  
 import org.mule.api.processor.MessageProcessor;
 17  
 import org.mule.context.notification.EndpointMessageNotification;
 18  
 import org.mule.transport.AbstractConnector;
 19  
 import org.mule.util.ObjectUtils;
 20  
 
 21  
 /**
 22  
  * Publishes a {@link EndpointMessageNotification}'s when a message is sent or
 23  
  * dispatched.
 24  
  */
 25  
 
 26  
 public class OutboundNotificationMessageProcessor implements MessageProcessor
 27  
 {
 28  
 
 29  
     private OutboundEndpoint endpoint;
 30  
 
 31  
     public OutboundNotificationMessageProcessor(OutboundEndpoint endpoint)
 32  0
     {
 33  0
         this.endpoint = endpoint;
 34  0
     }
 35  
 
 36  
     public MuleEvent process(MuleEvent event) throws MuleException
 37  
     {
 38  0
         AbstractConnector connector = (AbstractConnector) endpoint.getConnector();
 39  0
         if (connector.isEnableMessageEvents())
 40  
         {
 41  0
             String component = null;
 42  0
             if (event.getFlowConstruct() != null)
 43  
             {
 44  0
                 component = event.getFlowConstruct().getName();
 45  
             }
 46  
 
 47  
             int notificationAction;
 48  0
             if (event.getEndpoint().getExchangePattern().hasResponse())
 49  
             {
 50  0
                 notificationAction = EndpointMessageNotification.MESSAGE_SENT;
 51  
             }
 52  
             else
 53  
             {
 54  0
                 notificationAction = EndpointMessageNotification.MESSAGE_DISPATCHED;
 55  
             }
 56  0
             connector.fireNotification(new EndpointMessageNotification(event.getMessage(),
 57  
                 event.getEndpoint(), component, notificationAction));
 58  
         }
 59  
 
 60  0
         return event;
 61  
     }
 62  
 
 63  
     @Override
 64  
     public String toString()
 65  
     {
 66  0
         return ObjectUtils.toString(this);
 67  
     }
 68  
 }