Clover coverage report - Code Coverage for hivemind release 1.1-alpha-3
Coverage timestamp: Tue Mar 22 2005 09:10:26 EST
file stats: LOC: 203   Methods: 22
NCLOC: 138   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
ModuleImpl.java 100% 94.9% 90.9% 94%
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  227
     public List getConfiguration(String extensionPointId)
 56   
     {
 57  227
         String qualifiedId = IdUtils.qualify(_moduleId, extensionPointId);
 58   
 
 59  227
         return _registry.getConfiguration(qualifiedId, this);
 60   
     }
 61   
 
 62  111
     public boolean canConfigurationBeMapped(String configurationId)
 63   
     {
 64  111
         String qualifiedId = IdUtils.qualify(_moduleId, configurationId);
 65   
 
 66  111
         return _registry.getConfigurationPoint(qualifiedId, this).canElementsBeMapped();
 67   
     }
 68   
 
 69  111
     public Map getMappedConfiguration(String configurationId)
 70   
     {
 71  111
         String qualifiedId = IdUtils.qualify(_moduleId, configurationId);
 72   
 
 73  111
         return _registry.getConfigurationPoint(qualifiedId, this).getMappedElements();
 74   
     }
 75   
 
 76  444
     public String getModuleId()
 77   
     {
 78  444
         return _moduleId;
 79   
     }
 80   
 
 81   
     /** @since 1.1 */
 82   
 
 83  235
     public void setPackageName(String packageName)
 84   
     {
 85  235
         _packageName = packageName;
 86   
     }
 87   
 
 88  0
     public boolean containsService(Class serviceInterface)
 89   
     {
 90  0
         return _registry.containsService(serviceInterface, this);
 91   
     }
 92   
 
 93  2625
     public Object getService(String serviceId, Class serviceInterface)
 94   
     {
 95  2625
         String qualifiedId = IdUtils.qualify(_moduleId, serviceId);
 96   
 
 97  2625
         return _registry.getService(qualifiedId, serviceInterface, this);
 98   
     }
 99   
 
 100  130
     public Object getService(Class serviceInterface)
 101   
     {
 102  130
         return _registry.getService(serviceInterface, this);
 103   
     }
 104   
 
 105  231
     public void setModuleId(String string)
 106   
     {
 107  231
         _moduleId = string;
 108   
     }
 109   
 
 110  234
     public void setRegistry(RegistryInfrastructure registry)
 111   
     {
 112  234
         _registry = registry;
 113   
     }
 114   
 
 115  246
     public void setClassResolver(ClassResolver resolver)
 116   
     {
 117  246
         _resolver = resolver;
 118   
     }
 119   
 
 120  10
     public ClassResolver getClassResolver()
 121   
     {
 122  10
         return _resolver;
 123   
     }
 124   
 
 125  46
     public synchronized Messages getMessages()
 126   
     {
 127  46
         if (_messages == null)
 128   
         {
 129  8
             ThreadLocale threadLocale = (ThreadLocale) _registry.getService(
 130   
                     HiveMind.THREAD_LOCALE_SERVICE,
 131   
                     ThreadLocale.class,
 132   
                     this);
 133   
 
 134  8
             MessageFinder finder = new MessageFinderImpl(getLocation().getResource());
 135   
 
 136  8
             _messages = new ModuleMessages(finder, threadLocale);
 137   
         }
 138   
 
 139  46
         return _messages;
 140   
     }
 141   
 
 142  6127
     public String expandSymbols(String input, Location location)
 143   
     {
 144  6127
         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  443
     public ServicePoint getServicePoint(String serviceId)
 158   
     {
 159  443
         String qualifiedId = IdUtils.qualify(_moduleId, serviceId);
 160   
 
 161  443
         return _registry.getServicePoint(qualifiedId, this);
 162   
     }
 163   
 
 164  1238
     public ServiceModelFactory getServiceModelFactory(String name)
 165   
     {
 166  1238
         return _registry.getServiceModelFactory(name);
 167   
     }
 168   
 
 169  6683
     public Translator getTranslator(String translator)
 170   
     {
 171  6683
         return _registry.getTranslator(translator);
 172   
     }
 173   
 
 174  10
     public Locale getLocale()
 175   
     {
 176  10
         return _registry.getLocale();
 177   
     }
 178   
 
 179  924
     public ErrorHandler getErrorHandler()
 180   
     {
 181  924
         return _registry.getErrorHander();
 182   
     }
 183   
 
 184  0
     public String valueForSymbol(String symbol)
 185   
     {
 186  0
         return _registry.valueForSymbol(symbol);
 187   
     }
 188   
 
 189  8610
     public Class resolveType(String type)
 190   
     {
 191  8610
         Class result = _resolver.checkForClass(type);
 192   
 
 193  8610
         if (result == null)
 194  7197
             result = _resolver.checkForClass(_packageName + "." + type);
 195   
 
 196  8610
         if (result == null)
 197  3
             throw new ApplicationRuntimeException(ImplMessages.unableToConvertType(
 198   
                     type,
 199   
                     _packageName));
 200   
 
 201  8607
         return result;
 202   
     }
 203   
 }