List<Class<?>> customExtensionClassList = null;
try {
customExtensionClassList = ClassUtils.getSubClassesInPackage(packageName, AbstractExtension.class);
} catch (ClassNotFoundException e) {
throw new ExtensionLoadingException("Unable to load extensions", e);
} catch (IOException e) {
throw new ExtensionLoadingException("Unable to access the package '" + packageName + "'", e);
}
// Instanciate all found classes
for (Class<?> clazz : customExtensionClassList) {
try {
retval.add((AbstractExtension) ClassUtils.getClass(clazz.getName()).newInstance());
} catch (InstantiationException e) {
throw new ExtensionLoadingException("Unable to instanciate the class " + clazz.getName(), e);
} catch (IllegalAccessException e) {
throw new ExtensionLoadingException("Unable to access the class " + clazz.getName(), e);
} catch (ClassNotFoundException e) {
throw new ExtensionLoadingException("Unable to load the class " + clazz.getName(), e);
}
}
return retval;
}