use of org.opennms.upgrade.api.OnmsUpgradeComparator in project opennms by OpenNMS.
the class Upgrade method getUpgradeObjects.
/**
* Gets the upgrade objects.
*
* @return the upgrade objects
* @throws OnmsUpgradeException the OpenNMS upgrade exception
*/
protected List<OnmsUpgrade> getUpgradeObjects() throws OnmsUpgradeException {
List<OnmsUpgrade> upgrades = new ArrayList<>();
try {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
provider.addIncludeFilter(new AssignableTypeFilter(OnmsUpgrade.class));
Set<BeanDefinition> components = provider.findCandidateComponents(getClassScope());
for (BeanDefinition component : components) {
if (component.isAbstract()) {
continue;
}
Class<?> cls = Class.forName(component.getBeanClassName());
if (cls.getAnnotation(Ignore.class) != null) {
continue;
}
OnmsUpgrade upgrade = (OnmsUpgrade) cls.newInstance();
upgrades.add(upgrade);
log("Found upgrade task %s\n", upgrade.getId());
}
Collections.sort(upgrades, new OnmsUpgradeComparator());
} catch (Exception e) {
throw new OnmsUpgradeException(" Can't find the upgrade classes because: " + e.getMessage(), e);
}
return upgrades;
}
Aggregations