Coverage report

  %line %branch
org.apache.turbine.services.factory.TurbineFactory
25% 
100% 

 1  
 package org.apache.turbine.services.factory;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2005 The Apache Software Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License")
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import org.apache.turbine.services.TurbineServices;
 20  
 import org.apache.turbine.util.TurbineException;
 21  
 
 22  
 /**
 23  
  * The Factory Service instantiates objects using either default
 24  
  * class loaders or a specified one. Whether specified class
 25  
  * loaders are supported for a class depends on implementation
 26  
  * and can be tested with the isLoaderSupported method.
 27  
  *
 28  
  * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
 29  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 30  
  * @version $Id: TurbineFactory.java 264148 2005-08-29 14:21:04Z henning $
 31  
  */
 32  0
 public abstract class TurbineFactory
 33  
 {
 34  
     /**
 35  
      * Utility method for accessing the service
 36  
      * implementation
 37  
      *
 38  
      * @return An AssemblerBroker implementation instance
 39  
      */
 40  
     public static FactoryService getService()
 41  
     {
 42  352
         return (FactoryService) TurbineServices.getInstance()
 43  
                 .getService(FactoryService.SERVICE_NAME);
 44  
     }
 45  
     /**
 46  
      * Gets an instance of a named class.
 47  
      *
 48  
      * @param className the name of the class.
 49  
      * @return the instance.
 50  
      * @throws TurbineException if instantiation fails.
 51  
      */
 52  
     public static Object getInstance(String className)
 53  
             throws TurbineException
 54  
     {
 55  308
         return getService().getInstance(className);
 56  
     }
 57  
 
 58  
     /**
 59  
      * Gets an instance of a named class using a specified class loader.
 60  
      *
 61  
      * <p>Class loaders are supported only if the isLoaderSupported
 62  
      * method returns true. Otherwise the loader parameter is ignored.
 63  
      *
 64  
      * @param className the name of the class.
 65  
      * @param loader the class loader.
 66  
      * @return the instance.
 67  
      * @throws TurbineException if instantiation fails.
 68  
      */
 69  
     public static Object getInstance(String className,
 70  
             ClassLoader loader)
 71  
             throws TurbineException
 72  
     {
 73  0
         return getService().getInstance(className,
 74  
                 loader);
 75  
     }
 76  
 
 77  
     /**
 78  
      * Gets an instance of a named class.
 79  
      * Parameters for its constructor are given as an array of objects,
 80  
      * primitive types must be wrapped with a corresponding class.
 81  
      *
 82  
      * @param className the name of the class.
 83  
      * @param params an array containing the parameters of the constructor.
 84  
      * @param signature an array containing the signature of the constructor.
 85  
      * @return the instance.
 86  
      * @throws TurbineException if instantiation fails.
 87  
      */
 88  
     public static Object getInstance(String className,
 89  
             Object[] params,
 90  
             String[] signature)
 91  
             throws TurbineException
 92  
     {
 93  0
         return getService().getInstance(className,
 94  
                 params,
 95  
                 signature);
 96  
     }
 97  
 
 98  
     /**
 99  
      * Gets an instance of a named class using a specified class loader.
 100  
      * Parameters for its constructor are given as an array of objects,
 101  
      * primitive types must be wrapped with a corresponding class.
 102  
      *
 103  
      * <p>Class loaders are supported only if the isLoaderSupported
 104  
      * method returns true. Otherwise the loader parameter is ignored.
 105  
      *
 106  
      * @param className the name of the class.
 107  
      * @param loader the class loader.
 108  
      * @param params an array containing the parameters of the constructor.
 109  
      * @param signature an array containing the signature of the constructor.
 110  
      * @return the instance.
 111  
      * @throws TurbineException if instantiation fails.
 112  
      */
 113  
     public static Object getInstance(String className,
 114  
             ClassLoader loader,
 115  
             Object[] params,
 116  
             String[] signature)
 117  
             throws TurbineException
 118  
     {
 119  0
         return getService().getInstance(className,
 120  
                 loader,
 121  
                 params,
 122  
                 signature);
 123  
     }
 124  
 
 125  
 
 126  
     /**
 127  
      * Tests if specified class loaders are supported for a named class.
 128  
      *
 129  
      * @param className the name of the class.
 130  
      * @return true if class loaders are supported, false otherwise.
 131  
      * @throws TurbineException if test fails.
 132  
      */
 133  
     public static boolean isLoaderSupported(String className)
 134  
             throws TurbineException
 135  
     {
 136  0
         return getService().isLoaderSupported(className);
 137  
     }
 138  
 
 139  
     /**
 140  
      * Gets the signature classes for parameters of a method of a class.
 141  
      *
 142  
      * @param clazz the class.
 143  
      * @param params an array containing the parameters of the method.
 144  
      * @param signature an array containing the signature of the method.
 145  
      * @return an array of signature classes. Note that in some cases
 146  
      * objects in the parameter array can be switched to the context
 147  
      * of a different class loader.
 148  
      * @throws ClassNotFoundException if any of the classes is not found.
 149  
      */
 150  
     public static Class[] getSignature(Class clazz,
 151  
             Object params[],
 152  
             String signature[])
 153  
             throws ClassNotFoundException
 154  
     {
 155  0
         return getService().getSignature(clazz, params, signature);
 156  
     }
 157  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.