Search in sources :

Example 1 with XmlFileStorageAdapter

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;
}
Also used : XmlFileStorageAdapter(org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter) FeaturesService(org.apache.karaf.features.FeaturesService) Feature(org.apache.karaf.features.Feature) BundleContext(org.osgi.framework.BundleContext)

Aggregations

Feature (org.apache.karaf.features.Feature)1 FeaturesService (org.apache.karaf.features.FeaturesService)1 XmlFileStorageAdapter (org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter)1 BundleContext (org.osgi.framework.BundleContext)1