Clover coverage report - Code Coverage for hivemind-lib release 1.1-alpha-1
Coverage timestamp: Tue Jan 18 2005 07:56:07 EST
file stats: LOC: 77   Methods: 2
NCLOC: 40   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ChainFactory.java 100% 100% 100% 100%
coverage
 1   
 // Copyright 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.hivemind.lib.chain;
 16   
 
 17   
 import java.util.ArrayList;
 18   
 import java.util.Iterator;
 19   
 import java.util.List;
 20   
 
 21   
 import org.apache.hivemind.ServiceImplementationFactory;
 22   
 import org.apache.hivemind.ServiceImplementationFactoryParameters;
 23   
 import org.apache.hivemind.order.Orderer;
 24   
 
 25   
 /**
 26   
  * Builds a service implementation using {@link org.apache.hivemind.lib.chain.ChainBuilder}.
 27   
  * 
 28   
  * @author Howard M. Lewis Ship
 29   
  * @since 1.1
 30   
  */
 31   
 public class ChainFactory implements ServiceImplementationFactory
 32   
 {
 33   
     private ChainBuilder _chainBuilder;
 34   
 
 35  1
     public Object createCoreServiceImplementation(
 36   
             ServiceImplementationFactoryParameters factoryParameters)
 37   
     {
 38  1
         List contributions = (List) factoryParameters.getFirstParameter();
 39   
 
 40  1
         Orderer orderer = new Orderer(factoryParameters.getErrorLog(), "command");
 41   
 
 42  1
         Iterator i = contributions.iterator();
 43  1
         while (i.hasNext())
 44   
         {
 45  1
             ChainContribution cc = (ChainContribution) i.next();
 46  1
             orderer.add(cc, cc.getId(), cc.getAfter(), cc.getBefore());
 47   
         }
 48   
 
 49  1
         List ordered = orderer.getOrderedObjects();
 50   
 
 51  1
         List commands = new ArrayList(ordered.size());
 52   
 
 53  1
         i = ordered.iterator();
 54  1
         while (i.hasNext())
 55   
         {
 56  1
             ChainContribution cc = (ChainContribution) i.next();
 57   
 
 58   
             // TODO: Validate that command for each ChainContribution implements the
 59   
             // service interface.
 60   
 
 61  1
             commands.add(cc.getCommand());
 62   
         }
 63   
 
 64  1
         String toString = "<ChainImplementation for " + factoryParameters.getServiceId() + "("
 65   
                 + factoryParameters.getServiceInterface().getName() + ")>";
 66   
 
 67  1
         return _chainBuilder.buildImplementation(
 68   
                 factoryParameters.getServiceInterface(),
 69   
                 commands,
 70   
                 toString);
 71   
     }
 72   
 
 73  1
     public void setChainBuilder(ChainBuilder chainBuilder)
 74   
     {
 75  1
         _chainBuilder = chainBuilder;
 76   
     }
 77   
 }