Coverage Report - org.mule.endpoint.inbound.InboundLoggingMessageProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
InboundLoggingMessageProcessor
0%
0/14
0%
0/4
0
 
 1  
 /*
 2  
  * $Id: InboundLoggingMessageProcessor.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.inbound;
 12  
 
 13  
 import org.mule.api.MuleEvent;
 14  
 import org.mule.api.MuleException;
 15  
 import org.mule.api.MuleMessage;
 16  
 import org.mule.api.endpoint.InboundEndpoint;
 17  
 import org.mule.api.processor.MessageProcessor;
 18  
 import org.mule.util.ObjectUtils;
 19  
 import org.mule.util.StringMessageUtils;
 20  
 
 21  
 import org.apache.commons.logging.Log;
 22  
 import org.apache.commons.logging.LogFactory;
 23  
 
 24  
 public class InboundLoggingMessageProcessor implements MessageProcessor
 25  
 {
 26  0
     protected final transient Log logger = LogFactory.getLog(getClass());
 27  
     protected InboundEndpoint endpoint;
 28  
 
 29  
     public InboundLoggingMessageProcessor(InboundEndpoint endpoint)
 30  0
     {
 31  0
         this.endpoint = endpoint;
 32  0
     }
 33  
 
 34  
     public MuleEvent process(MuleEvent event) throws MuleException
 35  
     {
 36  0
         MuleMessage message = event.getMessage();
 37  0
         if (logger.isDebugEnabled())
 38  
         {
 39  0
             logger.debug("Message Received on: " + endpoint.getEndpointURI());
 40  
         }
 41  0
         if (logger.isTraceEnabled())
 42  
         {
 43  
             try
 44  
             {
 45  0
                 logger.trace("Message Payload: \n"
 46  
                              + StringMessageUtils.truncate(StringMessageUtils.toString(message.getPayload()),
 47  
                                  200, false));
 48  0
                 logger.trace("Message detail: \n" + StringMessageUtils.headersToString(message));
 49  
             }
 50  0
             catch (Exception e)
 51  
             {
 52  
                 // ignore
 53  0
             }
 54  
         }
 55  
 
 56  0
         return event;
 57  
     }
 58  
 
 59  
     @Override
 60  
     public String toString()
 61  
     {
 62  0
         return ObjectUtils.toString(this);
 63  
     }
 64  
 }