Clover coverage report - Code Coverage for tapestry release 4.0-beta-2
Coverage timestamp: Sat Jul 9 2005 22:02:17 EDT
file stats: LOC: 112   Methods: 6
NCLOC: 57   Classes: 1
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ComponentConstructorFactoryImpl.java 100% 92.9% 83.3% 90.9%
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.tapestry.services.impl;
 16   
 17    import java.util.Collections;
 18    import java.util.HashMap;
 19    import java.util.Map;
 20   
 21    import org.apache.hivemind.ClassResolver;
 22    import org.apache.hivemind.service.ClassFactory;
 23    import org.apache.tapestry.enhance.EnhancedClassValidator;
 24    import org.apache.tapestry.enhance.EnhancementOperationImpl;
 25    import org.apache.tapestry.enhance.EnhancementWorker;
 26    import org.apache.tapestry.event.ResetEventListener;
 27    import org.apache.tapestry.services.ComponentConstructor;
 28    import org.apache.tapestry.services.ComponentConstructorFactory;
 29    import org.apache.tapestry.spec.IComponentSpecification;
 30   
 31    /**
 32    * Implementation of the {@link org.apache.tapestry.services.ComponentConstructorFactory}service
 33    * interface.
 34    *
 35    * @author Howard M. Lewis Ship
 36    * @since 4.0
 37    */
 38    public class ComponentConstructorFactoryImpl implements ComponentConstructorFactory,
 39    ResetEventListener
 40    {
 41    private ClassFactory _classFactory;
 42   
 43    private ClassResolver _classResolver;
 44   
 45    private EnhancedClassValidator _validator;
 46   
 47    private EnhancementWorker _chain;
 48   
 49    /**
 50    * Map of {@link org.apache.tapestry.services.ComponentConstructor}keyed on
 51    * {@link org.apache.tapestry.spec.IComponentSpecification}.
 52    */
 53   
 54    private Map _cachedConstructors = Collections.synchronizedMap(new HashMap());
 55   
 56  0 public void resetEventDidOccur()
 57    {
 58  0 _cachedConstructors.clear();
 59    }
 60   
 61  1096 public ComponentConstructor getComponentConstructor(IComponentSpecification specification,
 62    String className)
 63    {
 64  1096 ComponentConstructor result = (ComponentConstructor) _cachedConstructors.get(specification);
 65   
 66  1096 if (result == null)
 67    {
 68  418 Class baseClass = _classResolver.findClass(className);
 69   
 70  418 EnhancementOperationImpl eo = new EnhancementOperationImpl(_classResolver,
 71    specification, baseClass, _classFactory);
 72   
 73    // Invoking on the chain is the same as invoking on every
 74    // object in the chain (because method performEnhancement() is type void).
 75   
 76  418 _chain.performEnhancement(eo, specification);
 77   
 78  418 result = eo.getConstructor();
 79   
 80    // TODO: This should be optional to work around that IBM JVM bug.
 81    // Also, to some degree, it should be passed into EnhancementOperationImpl,
 82    // as it generally only needs to be done if a enhanced class
 83    // is fabricated.
 84   
 85  418 _validator.validate(baseClass, result.getComponentClass(), specification);
 86   
 87  418 _cachedConstructors.put(specification, result);
 88    }
 89   
 90  1096 return result;
 91    }
 92   
 93  41 public void setClassFactory(ClassFactory classFactory)
 94    {
 95  41 _classFactory = classFactory;
 96    }
 97   
 98  41 public void setClassResolver(ClassResolver classResolver)
 99    {
 100  41 _classResolver = classResolver;
 101    }
 102   
 103  41 public void setValidator(EnhancedClassValidator validator)
 104    {
 105  41 _validator = validator;
 106    }
 107   
 108  41 public void setChain(EnhancementWorker chain)
 109    {
 110  41 _chain = chain;
 111    }
 112    }