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