Coverage Report - org.mule.routing.AbstractRouterCollection
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractRouterCollection
89%
24/27
62%
5/8
1.364
 
 1  
 /*
 2  
  * $Id: AbstractRouterCollection.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.routing;
 12  
 
 13  
 import org.mule.management.stats.RouterStatistics;
 14  
 import org.mule.umo.routing.UMORouter;
 15  
 import org.mule.umo.routing.UMORouterCatchAllStrategy;
 16  
 import org.mule.umo.routing.UMORouterCollection;
 17  
 
 18  
 import java.util.Iterator;
 19  
 import java.util.List;
 20  
 
 21  
 import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList;
 22  
 import org.apache.commons.logging.Log;
 23  
 import org.apache.commons.logging.LogFactory;
 24  
 
 25  
 /**
 26  
  * <code>AbstractRouterCollection</code> provides common method implementations of
 27  
  * router collections for in and outbound routers.
 28  
  */
 29  
 
 30  
 public abstract class AbstractRouterCollection implements UMORouterCollection
 31  
 {
 32  
     /**
 33  
      * logger used by this class
 34  
      */
 35  888
     protected final transient Log logger = LogFactory.getLog(getClass());
 36  
 
 37  888
     protected boolean matchAll = false;
 38  
 
 39  888
     protected List routers = new CopyOnWriteArrayList();
 40  
 
 41  
     private RouterStatistics statistics;
 42  
 
 43  
     private UMORouterCatchAllStrategy catchAllStrategy;
 44  
 
 45  
     public AbstractRouterCollection(int type)
 46  888
     {
 47  888
         statistics = new RouterStatistics(type);
 48  888
     }
 49  
 
 50  
     public void setRouters(List routers)
 51  
     {
 52  2
         for (Iterator iterator = routers.iterator(); iterator.hasNext();)
 53  
         {
 54  4
             addRouter((UMORouter) iterator.next());
 55  
         }
 56  2
     }
 57  
 
 58  
     public void addRouter(UMORouter router)
 59  
     {
 60  426
         router.setRouterStatistics(getStatistics());
 61  426
         routers.add(router);
 62  426
     }
 63  
 
 64  
     public UMORouter removeRouter(UMORouter router)
 65  
     {
 66  2
         if (routers.remove(router))
 67  
         {
 68  2
             return router;
 69  
         }
 70  
         else
 71  
         {
 72  0
             return null;
 73  
         }
 74  
     }
 75  
 
 76  
     public List getRouters()
 77  
     {
 78  62
         return routers;
 79  
     }
 80  
 
 81  
     public UMORouterCatchAllStrategy getCatchAllStrategy()
 82  
     {
 83  476
         return catchAllStrategy;
 84  
     }
 85  
 
 86  
     public void setCatchAllStrategy(UMORouterCatchAllStrategy catchAllStrategy)
 87  
     {
 88  34
         this.catchAllStrategy = catchAllStrategy;
 89  34
         if (this.catchAllStrategy != null && catchAllStrategy instanceof AbstractCatchAllStrategy)
 90  
         {
 91  34
             ((AbstractCatchAllStrategy) this.catchAllStrategy).setStatistics(statistics);
 92  
         }
 93  34
     }
 94  
 
 95  
     public boolean isMatchAll()
 96  
     {
 97  16
         return matchAll;
 98  
     }
 99  
 
 100  
     public void setMatchAll(boolean matchAll)
 101  
     {
 102  2
         this.matchAll = matchAll;
 103  2
     }
 104  
 
 105  
     public RouterStatistics getStatistics()
 106  
     {
 107  542
         return statistics;
 108  
     }
 109  
 
 110  
     public void setStatistics(RouterStatistics stat)
 111  
     {
 112  0
         this.statistics = stat;
 113  0
     }
 114  
 }