2009/04/15 - Apache HiveMind has been retired.

For more information, please explore the Attic.

Clover coverage report - Code Coverage for hivemind-examples release 1.2.1
Coverage timestamp: Fri Feb 10 2006 16:34:25 PST
file stats: LOC: 108   Methods: 9
NCLOC: 68   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SetterService.java - 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.examples.setters;
 16   
 17    import java.io.IOException;
 18    import java.util.Collection;
 19    import java.util.List;
 20    import java.util.Properties;
 21   
 22    import org.apache.examples.Adder;
 23    import org.apache.hivemind.Resource;
 24   
 25    /**
 26    * Demonstrates the use of setter based dependency injection using the BuilderFactory.
 27    *
 28    * @author Achim Huegen
 29    */
 30    public class SetterService implements Runnable
 31    {
 32    private String _stringValue;
 33   
 34    private int _intValue;
 35   
 36    private double _doubleValue;
 37   
 38    private Adder _adderService;
 39   
 40    private List _configuration;
 41   
 42    private Collection _container;
 43   
 44    private Resource _textResource;
 45   
 46  1 public void setAdderService(Adder adderService)
 47    {
 48  1 _adderService = adderService;
 49    }
 50   
 51  1 public void setConfiguration(List configuration)
 52    {
 53  1 _configuration = configuration;
 54    }
 55   
 56  1 public void setContainer(Collection container)
 57    {
 58  1 _container = container;
 59    }
 60   
 61  1 public void setDoubleValue(double doubleValue)
 62    {
 63  1 _doubleValue = doubleValue;
 64    }
 65   
 66  1 public void setIntValue(int intValue)
 67    {
 68  1 _intValue = intValue;
 69    }
 70   
 71  1 public void setStringValue(String stringValue)
 72    {
 73  1 _stringValue = stringValue;
 74    }
 75   
 76  1 public void setTextResource(Resource textResource)
 77    {
 78  1 _textResource = textResource;
 79    }
 80   
 81  1 public void run()
 82    {
 83  1 System.out.println("StringValue: " + _stringValue);
 84  1 System.out.println("IntValue: " + _intValue);
 85  1 System.out.println("DoubleValue: " + _doubleValue);
 86  1 System.out.println("AdderService result: " + _adderService.add(10, 20));
 87  1 System.out.println("Configuration size: " + _configuration.size());
 88  1 System.out.println("Container type: " + _container.getClass().getName());
 89  1 Properties properties = loadResource();
 90  1 System.out.println("Text resource content: " + properties.toString());
 91    }
 92   
 93    /**
 94    * Loads the properties file reference by property textResource
 95    */
 96  1 private Properties loadResource()
 97    {
 98  1 Properties properties = new Properties();
 99  1 try
 100    {
 101  1 properties.load(_textResource.getResourceURL().openStream());
 102    }
 103    catch (IOException ignore)
 104    {
 105    }
 106  1 return properties;
 107    }
 108    }