Clover coverage report - Code Coverage for tapestry release 4.0-beta-9
Coverage timestamp: Sat Oct 1 2005 08:36:20 EDT
file stats: LOC: 90   Methods: 3
NCLOC: 42   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ComponentConstructorImpl.java - 100% 100% 100%
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.enhance;
 16   
 17    import java.lang.reflect.Constructor;
 18   
 19    import org.apache.hivemind.ApplicationRuntimeException;
 20    import org.apache.hivemind.Location;
 21    import org.apache.hivemind.util.Defense;
 22    import org.apache.tapestry.services.ComponentConstructor;
 23   
 24    /**
 25    * @author Howard M. Lewis Ship
 26    * @since 4.0
 27    */
 28    public class ComponentConstructorImpl implements ComponentConstructor
 29    {
 30    private Location _location;
 31   
 32    private Constructor _constructor;
 33   
 34    private Object[] _parameters;
 35   
 36    private String _classFabString;
 37   
 38    /**
 39    * News instance of this class.
 40    *
 41    * @param constructor
 42    * the constructor method to invoke
 43    * @param parameters
 44    * the parameters to pass to the constructor. These are retained, not copied.
 45    * @param classFabString
 46    * a string representing the generated class information, used for exception
 47    * reporting
 48    * @param location
 49    * the location, used for exception reporting
 50    */
 51   
 52  604 public ComponentConstructorImpl(Constructor constructor, Object[] parameters,
 53    String classFabString, Location location)
 54    {
 55  604 Defense.notNull(constructor, "constructor");
 56  604 _constructor = constructor;
 57  604 _parameters = parameters;
 58  604 _classFabString = classFabString;
 59  604 _location = location;
 60    }
 61   
 62  418 public Class getComponentClass()
 63    {
 64  418 return _constructor.getDeclaringClass();
 65    }
 66   
 67  1291 public Object newInstance()
 68    {
 69  1291 try
 70    {
 71  1291 Object result = _constructor.newInstance(_parameters);
 72   
 73    // Unlikely to generate an error if we can get through it once, so it's
 74    // safe to release the big classFabString
 75   
 76  1290 _classFabString = null;
 77   
 78  1290 return result;
 79    }
 80    catch (Throwable ex)
 81    {
 82  1 throw new ApplicationRuntimeException(EnhanceMessages.instantiationFailure(
 83    _constructor,
 84    _parameters,
 85    _classFabString,
 86    ex), null, _location, ex);
 87    }
 88    }
 89   
 90    }