*/
package org.opendaylight.controller.md.inventory.manager;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class InventoryActivator extends AbstractBindingAwareProvider {
-
- private static FlowCapableInventoryProvider provider = new FlowCapableInventoryProvider();
+ private static final Logger LOG = LoggerFactory.getLogger(InventoryActivator.class);
+ private FlowCapableInventoryProvider provider;
@Override
public void onSessionInitiated(final ProviderContext session) {
- DataProviderService salDataService = session.<DataProviderService> getSALService(DataProviderService.class);
+ DataBroker dataBroker = session.getSALService(DataBroker.class);
NotificationProviderService salNotifiService =
- session.<NotificationProviderService> getSALService(NotificationProviderService.class);
- InventoryActivator.provider.setDataService(salDataService);
- InventoryActivator.provider.setNotificationService(salNotifiService);
- InventoryActivator.provider.start();
+ session.getSALService(NotificationProviderService.class);
+
+ provider = new FlowCapableInventoryProvider(dataBroker, salNotifiService);
+ provider.start();
}
@Override
protected void stopImpl(final BundleContext context) {
- InventoryActivator.provider.close();
+ if (provider != null) {
+ try {
+ provider.close();
+ } catch (InterruptedException e) {
+ LOG.warn("Interrupted while waiting for shutdown", e);
+ }
+ provider = null;
+ }
}
}