Coverage Report - org.mule.component.simple.LogComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
LogComponent
0%
0/9
N/A
1
 
 1  
 /*
 2  
  * $Id: LogComponent.java 19191 2010-08-25 21:05:23Z 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.component.simple;
 12  
 
 13  
 import org.mule.api.MuleEventContext;
 14  
 import org.mule.api.component.simple.LogService;
 15  
 import org.mule.api.lifecycle.Callable;
 16  
 import org.mule.util.StringMessageUtils;
 17  
 
 18  
 import org.apache.commons.logging.Log;
 19  
 import org.apache.commons.logging.LogFactory;
 20  
 
 21  
 /**
 22  
  * <code>LogComponent</code> simply logs the content (or content length if it is a
 23  
  * large message)
 24  
  */
 25  0
 public class LogComponent implements Callable, LogService
 26  
 {
 27  0
     private static Log logger = LogFactory.getLog(LogComponent.class);
 28  
 
 29  
     public Object onCall(MuleEventContext context) throws Exception
 30  
     {
 31  0
         String contents = context.getMessageAsString();
 32  0
         String msg = "Message received in service: " + context.getFlowConstruct().getName();
 33  0
         msg = StringMessageUtils.getBoilerPlate(msg + ". Content is: '"
 34  
                         + StringMessageUtils.truncate(contents, 100, true) + "'");
 35  0
         log(msg);
 36  0
         return context.getMessage();
 37  
     }
 38  
 
 39  
     public void log(String message)
 40  
     {
 41  0
         logger.info(message);
 42  0
     }
 43  
 }