Coverage Report - org.mule.interceptor.AbstractEnvelopeInterceptor
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractEnvelopeInterceptor
0%
0/14
N/A
1
 
 1  
 /*
 2  
  * $Id: AbstractEnvelopeInterceptor.java 20288 2010-11-22 01:19:54Z mike.schilling $
 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.interceptor;
 12  
 
 13  
 import org.mule.api.MuleEvent;
 14  
 import org.mule.api.MuleException;
 15  
 import org.mule.api.construct.FlowConstruct;
 16  
 import org.mule.api.construct.FlowConstructAware;
 17  
 import org.mule.api.interceptor.Interceptor;
 18  
 import org.mule.management.stats.ProcessingTime;
 19  
 import org.mule.processor.AbstractInterceptingMessageProcessor;
 20  
 
 21  
 /**
 22  
  * <code>EnvelopeInterceptor</code> is an intercepter that will fire before and after
 23  
  * an event is received.
 24  
  */
 25  0
 public abstract class AbstractEnvelopeInterceptor extends AbstractInterceptingMessageProcessor
 26  
                                                   implements Interceptor, FlowConstructAware
 27  
 {
 28  
 
 29  
     protected FlowConstruct flowConstruct;
 30  
 
 31  
     /**
 32  
      * This method is invoked before the event is processed
 33  
      */
 34  
     public abstract MuleEvent before(MuleEvent event) throws MuleException;
 35  
 
 36  
     /**
 37  
      * This method is invoked after the event has been processed, unless an exception was thrown
 38  
      */
 39  
     public abstract MuleEvent after(MuleEvent event) throws MuleException;
 40  
 
 41  
     /**
 42  
      *  This method is always invoked after the event has been processed,
 43  
      */
 44  
     public abstract MuleEvent last(MuleEvent event, ProcessingTime time, long startTime, boolean exceptionWasThrown) throws MuleException;
 45  
 
 46  
     public MuleEvent process(MuleEvent event) throws MuleException
 47  
     {
 48  0
         boolean exceptionWasThrown = true;
 49  0
         long startTime = System.currentTimeMillis();
 50  0
         ProcessingTime time = event.getProcessingTime();
 51  0
         MuleEvent resultEvent = event;
 52  
         try
 53  
         {
 54  0
             resultEvent = before(event);
 55  0
             resultEvent = processNext(resultEvent);
 56  0
             resultEvent = after(resultEvent);
 57  0
             exceptionWasThrown = false;
 58  
         }
 59  
         finally
 60  
         {
 61  0
             resultEvent = last(resultEvent, time, startTime, exceptionWasThrown);
 62  0
         }
 63  0
         return resultEvent;
 64  
     }
 65  
 
 66  
     public void setFlowConstruct(FlowConstruct flowConstruct)
 67  
     {
 68  0
         this.flowConstruct = flowConstruct;
 69  0
     }
 70  
 }