Coverage Report - org.mule.api.processor.policy.TimingPolicy
 
Classes in this File Line Coverage Branch Coverage Complexity
TimingPolicy
0%
0/10
0%
0/2
1.5
 
 1  
 /*
 2  
  * $Id: TimingPolicy.java 20320 2010-11-24 15:03:31Z dfeist $
 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.api.processor.policy;
 12  
 
 13  
 import org.mule.api.MuleEvent;
 14  
 import org.mule.api.MuleException;
 15  
 
 16  
 import org.apache.commons.logging.Log;
 17  
 import org.apache.commons.logging.LogFactory;
 18  
 
 19  
 /**
 20  
  *
 21  
  */
 22  0
 public class TimingPolicy implements AroundPolicy
 23  
 {
 24  
 
 25  0
     protected final Log logger = LogFactory.getLog(getClass());
 26  
 
 27  
     public String getName()
 28  
     {
 29  0
         return "simple timing policy";
 30  
     }
 31  
 
 32  
     public MuleEvent invoke(PolicyInvocation invocation) throws MuleException
 33  
     {
 34  0
         final MuleEvent invocationEvent = invocation.getEvent();
 35  0
         long startTime = System.currentTimeMillis();
 36  
 
 37  0
         final MuleEvent result = invocation.proceed();
 38  
 
 39  0
         long executionTime = System.currentTimeMillis() - startTime;
 40  0
         if (logger.isInfoEnabled())
 41  
         {
 42  0
             logger.info(String.format("%s took %dms to process event [%s]",
 43  
                                           invocationEvent.getFlowConstruct().getName(),
 44  
                                           executionTime, invocationEvent.getId()));
 45  
         }
 46  
 
 47  0
         return result;
 48  
     }
 49  
 }