org.apache.ojb.broker.util
Class ConstructorHelper

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

public class ConstructorHelper
extends java.lang.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 365232 2005-12-21 22:36:07Z tomdz $
Author:
Thomas Mahler, Lance Eason

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

Method Detail

instantiate

public static java.lang.Object instantiate(java.lang.Class clazz)
                                    throws java.lang.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:
java.lang.InstantiationException

instantiate

public static java.lang.Object instantiate(java.lang.reflect.Constructor constructor)
                                    throws java.lang.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:
java.lang.InstantiationException
ClassNotPersistenceCapableException - if the constructor is null or there is an exception while trying to create a new instance


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30