Clover coverage report - Code Coverage for hivemind release 1.0-beta-2
Coverage timestamp: Sun Aug 1 2004 14:03:45 EDT
file stats: LOC: 129   Methods: 8
NCLOC: 77   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
InvokeFactoryServiceConstructor.java 100% 94.1% 100% 96.3%
coverage coverage
 1   
 //  Copyright 2004 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.impl;
 16   
 
 17   
 import java.util.List;
 18   
 
 19   
 import org.apache.hivemind.ApplicationRuntimeException;
 20   
 import org.apache.hivemind.ServiceImplementationFactory;
 21   
 import org.apache.hivemind.internal.Module;
 22   
 import org.apache.hivemind.internal.ServicePoint;
 23   
 import org.apache.hivemind.internal.ServiceImplementationConstructor;
 24   
 import org.apache.hivemind.schema.Schema;
 25   
 
 26   
 /**
 27   
  * Constructs a new service by invoking methods on
 28   
  * another service (which implements the
 29   
  * {@link org.apache.hivemind.ServiceImplementationFactory} interface.
 30   
  *
 31   
  * @author Howard Lewis Ship
 32   
  */
 33   
 public final class InvokeFactoryServiceConstructor
 34   
     extends BaseLocatable
 35   
     implements ServiceImplementationConstructor
 36   
 {
 37   
     private String _factoryServiceId;
 38   
     private ServicePoint _serviceExtensionPoint;
 39   
     private Module _contributingModule;
 40   
 
 41   
     /** List of {@link org.apache.hivemind.Element}, the raw XML parameters. */
 42   
     private List _parameters;
 43   
 
 44   
     /** The factory service to be invoked. */
 45   
     private ServiceImplementationFactory _factory;
 46   
 
 47   
     /** The parameters converted to objects as per the factory's parameter schema. */
 48   
     private List _convertedParameters;
 49   
 
 50  230
     public Object constructCoreServiceImplementation()
 51   
     {
 52  230
         if (_factory == null)
 53   
         {
 54  228
             ServicePoint factoryPoint = _contributingModule.getServicePoint(_factoryServiceId);
 55   
 
 56  228
             _factory =
 57   
                 (ServiceImplementationFactory) factoryPoint.getService(
 58   
                     ServiceImplementationFactory.class);
 59   
 
 60  228
             Schema schema = factoryPoint.getParametersSchema();
 61   
 
 62   
             // Note: it's kind of a toss up whether logging should occur using the
 63   
             // id of the service being constructed, or of the factory being invoked.
 64   
             // Here, we're using the constructed service ... with the intent being that
 65   
             // users will enable debugging for the service (or search the logs for the service)
 66   
             // if it fails to build properly.
 67   
         
 68  228
             SchemaProcessorImpl processor =
 69   
                 new SchemaProcessorImpl(
 70   
                     _contributingModule.getErrorHandler(),
 71   
                     _serviceExtensionPoint.getServiceLog(),
 72   
                     schema);
 73   
 
 74  228
             processor.process(_parameters, _contributingModule);
 75   
 
 76  228
             _convertedParameters = processor.getElements();
 77   
         }
 78   
 
 79  230
         try
 80   
         {
 81  230
             return _factory.createCoreServiceImplementation(
 82   
                 _serviceExtensionPoint.getExtensionPointId(),
 83   
                 _serviceExtensionPoint.getServiceInterface(),
 84   
                 _contributingModule,
 85   
                 _convertedParameters);
 86   
         }
 87   
         catch (Exception ex)
 88   
         {
 89  0
             throw new ApplicationRuntimeException(ex.getMessage(), getLocation(), ex);
 90   
         }
 91   
     }
 92   
 
 93  1
     public Module getContributingModule()
 94   
     {
 95  1
         return _contributingModule;
 96   
     }
 97   
 
 98  710
     public void setContributingModule(Module module)
 99   
     {
 100  710
         _contributingModule = module;
 101   
     }
 102   
 
 103  1
     public List getParameters()
 104   
     {
 105  1
         return _parameters;
 106   
     }
 107   
 
 108  1
     public ServicePoint getServiceExtensionPoint()
 109   
     {
 110  1
         return _serviceExtensionPoint;
 111   
     }
 112   
 
 113  710
     public void setParameters(List list)
 114   
     {
 115  710
         _parameters = list;
 116   
     }
 117   
 
 118  709
     public void setFactoryServiceId(String string)
 119   
     {
 120  709
         _factoryServiceId = string;
 121   
     }
 122   
 
 123  710
     public void setServiceExtensionPoint(ServicePoint point)
 124   
     {
 125  710
         _serviceExtensionPoint = point;
 126   
     }
 127   
 
 128   
 }
 129