use of org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter in project controller by opendaylight.
the class FeatureServiceCustomizer method addingService.
@Override
@SuppressWarnings("IllegalCatch")
public FeaturesService addingService(final ServiceReference<FeaturesService> reference) {
BundleContext bc = reference.getBundle().getBundleContext();
final FeaturesService featureService = bc.getService(reference);
final Optional<XmlFileStorageAdapter> currentPersister = XmlFileStorageAdapter.getInstance();
if (XmlFileStorageAdapter.getInstance().isPresent()) {
final Set<String> installedFeatureIds = Sets.newHashSet();
try {
for (final Feature installedFeature : featureService.listInstalledFeatures()) {
installedFeatureIds.add(installedFeature.getId());
}
} catch (final Exception e) {
LOG.error("Error listing installed features", e);
}
currentPersister.get().setFeaturesService(() -> installedFeatureIds);
}
ConfigFeaturesListener configFeaturesListener = new ConfigFeaturesListener(configPusher, featureService);
registration = bc.registerService(FeaturesListener.class.getCanonicalName(), configFeaturesListener, null);
return featureService;
}
Aggregations