org.apache.ojb.broker.util
Class ConstructorHelper

java.lang.Object
  extended by org.apache.ojb.broker.util.ConstructorHelper

public class ConstructorHelper
extends Object

This class helps us to construct new instances. We don't want to rely on public default constructors and have to try hard to also use private or protected constructors.

Version:
$Id: ConstructorHelper.java,v 1.1 2007-08-24 22:17:36 ewestfal Exp $
Author:
Thomas Mahler, Lance Eason

Method Summary
static Object instantiate(Class clazz)
          create a new instance of class clazz.
static Object instantiate(Constructor constructor)
          create a new instance of the class represented by the no-argument constructor provided
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instantiate

public static Object instantiate(Class clazz)
                          throws InstantiationException
create a new instance of class clazz. first use the public default constructor. If this fails also try to use protected an private constructors.

Parameters:
clazz - the class to instantiate
Returns:
the fresh instance of class clazz
Throws:
InstantiationException

instantiate

public static Object instantiate(Constructor constructor)
                          throws InstantiationException
create a new instance of the class represented by the no-argument constructor provided

Parameters:
constructor - the zero argument constructor for the class
Returns:
a new instance of the class
Throws:
InstantiationException
ClassNotPersistenceCapableException - if the constructor is null or there is an exception while trying to create a new instance


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.