Coverage Report - org.mule.impl.InterceptorsInvoker
 
Classes in this File Line Coverage Branch Coverage Complexity
InterceptorsInvoker
85%
11/13
100%
2/2
1.5
 
 1  
 /*
 2  
  * $Id: InterceptorsInvoker.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.impl;
 12  
 
 13  
 import org.mule.umo.Invocation;
 14  
 import org.mule.umo.UMOException;
 15  
 import org.mule.umo.UMOImmutableDescriptor;
 16  
 import org.mule.umo.UMOInterceptor;
 17  
 import org.mule.umo.UMOMessage;
 18  
 
 19  
 import java.util.List;
 20  
 
 21  
 /**
 22  
  * <code>InterceptorsInvoker</code> is used to trigger an interceptor chain.
 23  
  */
 24  
 
 25  
 public class InterceptorsInvoker extends Invocation
 26  
 {
 27  
     private final List interceptors;
 28  8
     private int cursor = 0;
 29  
 
 30  
     public InterceptorsInvoker(List interceptors, MuleDescriptor descriptor, UMOMessage message)
 31  
     {
 32  0
         this(interceptors, new ImmutableMuleDescriptor(descriptor), message);
 33  0
     }
 34  
 
 35  
     public InterceptorsInvoker(List interceptors, UMOImmutableDescriptor descriptor, UMOMessage message)
 36  
     {
 37  8
         super(descriptor, message, null);
 38  8
         this.interceptors = interceptors;
 39  8
     }
 40  
 
 41  
     public UMOMessage execute() throws UMOException
 42  
     {
 43  10
         if (cursor < interceptors.size())
 44  
         {
 45  8
             UMOInterceptor interceptor = (UMOInterceptor) interceptors.get(cursor);
 46  8
             incCursor();
 47  8
             return interceptor.intercept(this);
 48  
         }
 49  2
         return getMessage();
 50  
     }
 51  
 
 52  
     private synchronized void incCursor()
 53  
     {
 54  8
         cursor++;
 55  8
     }
 56  
 
 57  
 }