@SuppressWarnings("unchecked")
  public <T> T getLibraryInstance(Injector injector, String className) throws Exception {
    Class<? extends T> clazz;

    if (null != libraryClassLoader) {
      clazz = (Class<? extends T>) libraryClassLoader.loadClass(className);
    } else {
      clazz = (Class<? extends T>) Class.forName(className);
    }

    return (null == injector) ? clazz.newInstance() : injector.getInstance(clazz);
  }
Loads an instance of the class from the stack classloader, if available.

@param injector
         the injector to use, or {@code null} to invoke the default, no-arg
         constructor
@param className
         the name of the class to get an instance
@return
         the instance of the class
@throws Exception
         when the class cannot be loaded or instantiated
ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java