if (log.isDebugEnabled()) {
log.debug("Loading class [" + className + "] via classloader [" + loader + ']');
}
if (loader == null) {
throw new PluginContainerException("Cannot load class [" + className + "] with null classloader");
}
try {
Class<?> clazz = Class.forName(className, true, loader);
if (log.isDebugEnabled()) {
log.debug("Loaded class [" + clazz + "] from classloader [" + loader + ']');
}
return clazz.newInstance();
} catch (InstantiationException e) {
throw new PluginContainerException("Could not instantiate plugin class [" + className
+ "] from classloader [" + loader + "]", e);
} catch (IllegalAccessException e) {
throw new PluginContainerException("Could not access plugin class [" + className + "] from classloader ["
+ loader + "]", e);
} catch (ClassNotFoundException e) {
throw new PluginContainerException("Could not find plugin class [" + className + "] from classloader ["
+ loader + "]", e);
} catch (NullPointerException npe) {
throw new PluginContainerException("Plugin class was 'null' using loader [" + loader + "]", npe);
}
}