src/main/java/org/jboss/util/Classes.java
public static Object instantiate(Class expected, String property, String defaultClassName)
   {
      String className = getProperty(property, defaultClassName);
      Class clazz = null;
      try
      {
         clazz = loadClass(className);
      }
      catch (ClassNotFoundException e)
      {
         throw new NestedRuntimeException("Cannot load class " + className, e);
      }
      Object result = null;
      try
      {
         result = clazz.newInstance();
      }
      catch (InstantiationException e)
      {
         throw new NestedRuntimeException("Error instantiating " + className, e);
      }
      catch (IllegalAccessException e)
      {
         throw new NestedRuntimeException("Error instantiating " + className, e);
      }
      if (expected.isAssignableFrom(clazz) == false)
         throw new NestedRuntimeException("Class " + className + " from classloader " + clazz.getClassLoader() +
            " is not of the expected class " + expected + " loaded from " + expected.getClassLoader());
      return result;
   }
public static Object instantiate(Class expected, String property, String defaultClassName)
   {
      String className = getProperty(property, defaultClassName);
      Class clazz = null;
      try
      {
         clazz = loadClass(className);
      }
      catch (ClassNotFoundException e)
      {
         throw new NestedRuntimeException("Cannot load class " + className, e);
      }
      Object result = null;
      try
      {
         result = clazz.newInstance();
      }
      catch (InstantiationException e)
      {
         throw new NestedRuntimeException("Error instantiating " + className, e);
      }
      catch (IllegalAccessException e)
      {
         throw new NestedRuntimeException("Error instantiating " + className, e);
      }
      if (expected.isAssignableFrom(clazz) == false)
         throw new NestedRuntimeException("Class " + className + " from classloader " + clazz.getClassLoader() +
            " is not of the expected class " + expected + " loaded from " + expected.getClassLoader());
      return result;
   }
Instantiate a java class object

@param expected the expected class type
@param property the system property defining the class
@param defaultClassName the default class name
@return the instantiated object