Clover coverage report - Code Coverage for hivemind release 1.1
Coverage timestamp: Tue Oct 25 2005 10:47:07 EDT
file stats: LOC: 203   Methods: 22
NCLOC: 138   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ModuleImpl.java 100% 97.4% 95.5% 97%
coverage coverage
 1    // Copyright 2004, 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.impl;
 16   
 17    import java.util.List;
 18    import java.util.Locale;
 19    import java.util.Map;
 20   
 21    import org.apache.hivemind.ApplicationRuntimeException;
 22    import org.apache.hivemind.ClassResolver;
 23    import org.apache.hivemind.ErrorHandler;
 24    import org.apache.hivemind.HiveMind;
 25    import org.apache.hivemind.Location;
 26    import org.apache.hivemind.Messages;
 27    import org.apache.hivemind.internal.MessageFinder;
 28    import org.apache.hivemind.internal.Module;
 29    import org.apache.hivemind.internal.RegistryInfrastructure;
 30    import org.apache.hivemind.internal.ServiceModelFactory;
 31    import org.apache.hivemind.internal.ServicePoint;
 32    import org.apache.hivemind.schema.Translator;
 33    import org.apache.hivemind.service.ThreadLocale;
 34    import org.apache.hivemind.util.IdUtils;
 35    import org.apache.hivemind.util.ToStringBuilder;
 36   
 37    /**
 38    * Implementation of {@link org.apache.hivemind.internal.Module}.
 39    *
 40    * @author Howard Lewis Ship
 41    */
 42    public final class ModuleImpl extends BaseLocatable implements Module
 43    {
 44    private String _moduleId;
 45   
 46    /** @since 1.1 */
 47    private String _packageName;
 48   
 49    private RegistryInfrastructure _registry;
 50   
 51    private ClassResolver _resolver;
 52   
 53    private Messages _messages;
 54   
 55  254 public List getConfiguration(String extensionPointId)
 56    {
 57  254 String qualifiedId = IdUtils.qualify(_moduleId, extensionPointId);
 58   
 59  254 return _registry.getConfiguration(qualifiedId, this);
 60    }
 61   
 62  124 public boolean isConfigurationMappable(String configurationId)
 63    {
 64  124 String qualifiedId = IdUtils.qualify(_moduleId, configurationId);
 65   
 66  124 return _registry.getConfigurationPoint(qualifiedId, this).areElementsMappable();
 67    }
 68   
 69  124 public Map getConfigurationAsMap(String configurationId)
 70    {
 71  124 String qualifiedId = IdUtils.qualify(_moduleId, configurationId);
 72   
 73  124 return _registry.getConfigurationPoint(qualifiedId, this).getElementsAsMap();
 74    }
 75   
 76  497 public String getModuleId()
 77    {
 78  497 return _moduleId;
 79    }
 80   
 81    /** @since 1.1 */
 82   
 83  263 public void setPackageName(String packageName)
 84    {
 85  263 _packageName = packageName;
 86    }
 87   
 88  279 public boolean containsService(Class serviceInterface)
 89    {
 90  279 return _registry.containsService(serviceInterface, this);
 91    }
 92   
 93  3005 public Object getService(String serviceId, Class serviceInterface)
 94    {
 95  3005 String qualifiedId = IdUtils.qualify(_moduleId, serviceId);
 96   
 97  3005 return _registry.getService(qualifiedId, serviceInterface, this);
 98    }
 99   
 100  144 public Object getService(Class serviceInterface)
 101    {
 102  144 return _registry.getService(serviceInterface, this);
 103    }
 104   
 105  263 public void setModuleId(String string)
 106    {
 107  263 _moduleId = string;
 108    }
 109   
 110  262 public void setRegistry(RegistryInfrastructure registry)
 111    {
 112  262 _registry = registry;
 113    }
 114   
 115  276 public void setClassResolver(ClassResolver resolver)
 116    {
 117  276 _resolver = resolver;
 118    }
 119   
 120  10 public ClassResolver getClassResolver()
 121    {
 122  10 return _resolver;
 123    }
 124   
 125  47 public synchronized Messages getMessages()
 126    {
 127  47 if (_messages == null)
 128    {
 129  9 ThreadLocale threadLocale = (ThreadLocale) _registry.getService(
 130    HiveMind.THREAD_LOCALE_SERVICE,
 131    ThreadLocale.class,
 132    this);
 133   
 134  9 MessageFinder finder = new MessageFinderImpl(getLocation().getResource());
 135   
 136  9 _messages = new ModuleMessages(finder, threadLocale);
 137    }
 138   
 139  47 return _messages;
 140    }
 141   
 142  7162 public String expandSymbols(String input, Location location)
 143    {
 144  7162 return _registry.expandSymbols(input, location);
 145    }
 146   
 147  4 public String toString()
 148    {
 149  4 ToStringBuilder builder = new ToStringBuilder(this);
 150   
 151  4 builder.append("moduleId", _moduleId);
 152  4 builder.append("classResolver", _resolver);
 153   
 154  4 return builder.toString();
 155    }
 156   
 157  514 public ServicePoint getServicePoint(String serviceId)
 158    {
 159  514 String qualifiedId = IdUtils.qualify(_moduleId, serviceId);
 160   
 161  514 return _registry.getServicePoint(qualifiedId, this);
 162    }
 163   
 164  1413 public ServiceModelFactory getServiceModelFactory(String name)
 165    {
 166  1413 return _registry.getServiceModelFactory(name);
 167    }
 168   
 169  8903 public Translator getTranslator(String translator)
 170    {
 171  8903 return _registry.getTranslator(translator);
 172    }
 173   
 174  11 public Locale getLocale()
 175    {
 176  11 return _registry.getLocale();
 177    }
 178   
 179  1051 public ErrorHandler getErrorHandler()
 180    {
 181  1051 return _registry.getErrorHander();
 182    }
 183   
 184  0 public String valueForSymbol(String symbol)
 185    {
 186  0 return _registry.valueForSymbol(symbol);
 187    }
 188   
 189  10100 public Class resolveType(String type)
 190    {
 191  10100 Class result = _resolver.checkForClass(type);
 192   
 193  10100 if (result == null)
 194  8501 result = _resolver.checkForClass(_packageName + "." + type);
 195   
 196  10100 if (result == null)
 197  3 throw new ApplicationRuntimeException(ImplMessages.unableToConvertType(
 198    type,
 199    _packageName));
 200   
 201  10097 return result;
 202    }
 203    }