Bug 8568: Remove deprecated MountProviderService from RootBindingAwareBroker
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / impl / RootBindingAwareBroker.java
index 3ad1dabffe0b39958b65019274b459fae167d8bb..d91737154754750a1e3a2aa309c9c8953ee63854 100644 (file)
@@ -7,7 +7,12 @@
  */
 package org.opendaylight.controller.sal.binding.impl;
 
+import static com.google.common.base.Preconditions.checkState;
+
 import com.google.common.collect.ImmutableClassToInstanceMap;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.binding.util.AbstractBindingSalProviderInstance;
 import org.opendaylight.controller.md.sal.binding.util.BindingContextUtils;
 import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
@@ -19,10 +24,6 @@ import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.controller.sal.binding.api.NotificationService;
 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
-import org.opendaylight.controller.sal.binding.api.mount.MountService;
 import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
@@ -32,12 +33,8 @@ import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import static com.google.common.base.Preconditions.checkState;
 
-public class RootBindingAwareBroker implements //
-        Mutable, //
-        Identifiable<String>, //
-        BindingAwareBroker, AutoCloseable,
+public class RootBindingAwareBroker implements Mutable, Identifiable<String>, BindingAwareBroker, AutoCloseable,
         RpcProviderRegistry {
 
     private final static Logger LOG = LoggerFactory.getLogger(RootBindingAwareBroker.class);
@@ -50,27 +47,21 @@ public class RootBindingAwareBroker implements //
 
     private NotificationProviderService notificationBroker;
 
-    private DataProviderService dataBroker;
+    private NotificationPublishService notificationPublishService;
 
-    private MountPointManagerImpl mountManager;
-
-    public MountPointManagerImpl getMountManager() {
-        return mountManager;
-    }
-
-    public void setMountManager(MountPointManagerImpl mountManager) {
-        this.mountManager = mountManager;
-    }
+    private DataBroker dataBroker;
 
     private ImmutableClassToInstanceMap<BindingAwareService> supportedConsumerServices;
 
     private ImmutableClassToInstanceMap<BindingAwareService> supportedProviderServices;
 
-    public RootBindingAwareBroker(String instanceName) {
+    private MountPointService mountService;
+
+    public RootBindingAwareBroker(final String instanceName) {
         this.identifier = instanceName;
-        mountManager = new MountPointManagerImpl();
     }
 
+    @Override
     public String getIdentifier() {
         return identifier;
     }
@@ -79,14 +70,14 @@ public class RootBindingAwareBroker implements //
         return controllerRoot;
     }
 
-    public DataProviderService getDataBroker() {
-        return this.dataBroker;
-    }
-
     public NotificationProviderService getNotificationBroker() {
         return this.notificationBroker;
     }
 
+    public NotificationPublishService getNotificationPublishService() {
+        return this.notificationPublishService;
+    }
+
     public RpcProviderRegistry getRpcProviderRegistry() {
         return this.rpcBroker;
     }
@@ -95,47 +86,76 @@ public class RootBindingAwareBroker implements //
         return rpcBroker;
     }
 
-    public void setRpcBroker(RpcProviderRegistry rpcBroker) {
+    public MountPointService getMountService() {
+        return mountService;
+    }
+
+    public void setDataBroker(final DataBroker asyncDataBroker) {
+        dataBroker = asyncDataBroker;
+    }
+
+    public void setMountService(final MountPointService mount) {
+        this.mountService = mount;
+    }
+
+    public void setRpcBroker(final RpcProviderRegistry rpcBroker) {
         this.rpcBroker = rpcBroker;
     }
 
-    public void setNotificationBroker(NotificationProviderService notificationBroker) {
+    public void setNotificationBroker(final NotificationProviderService notificationBroker) {
         this.notificationBroker = notificationBroker;
     }
 
-    public void setDataBroker(DataProviderService dataBroker) {
-        this.dataBroker = dataBroker;
+    public void setNotificationPublishService(final NotificationPublishService notificationPublishService) {
+        this.notificationPublishService = notificationPublishService;
     }
 
     public void start() {
         checkState(controllerRoot == null, "Binding Aware Broker was already started.");
         LOG.info("Starting Binding Aware Broker: {}", identifier);
 
-        controllerRoot = new RootSalInstance(getRpcProviderRegistry(), getNotificationBroker(), getDataBroker());
-        
+        controllerRoot = new RootSalInstance(getRpcProviderRegistry(), getNotificationBroker());
+
+        final ImmutableClassToInstanceMap.Builder<BindingAwareService> consBuilder = ImmutableClassToInstanceMap
+                .builder();
 
-        supportedConsumerServices = ImmutableClassToInstanceMap.<BindingAwareService> builder()
-                .put(NotificationService.class, getRoot()) //
-                .put(DataBrokerService.class, getRoot()) //
-                .put(RpcConsumerRegistry.class, getRoot()) //
-                .put(MountService.class, mountManager).build();
+        consBuilder.put(NotificationService.class, getRoot());
+        consBuilder.put(RpcConsumerRegistry.class, getRoot());
+        if (dataBroker != null) {
+            consBuilder.put(DataBroker.class, dataBroker);
+        }
+        consBuilder.put(MountPointService.class, mountService);
+
+        supportedConsumerServices = consBuilder.build();
+        final ImmutableClassToInstanceMap.Builder<BindingAwareService> provBuilder = ImmutableClassToInstanceMap
+                .builder();
+        provBuilder.putAll(supportedConsumerServices).put(NotificationProviderService.class, getRoot())
+                .put(RpcProviderRegistry.class, getRoot());
+        if (notificationPublishService != null) {
+            provBuilder.put(NotificationPublishService.class, notificationPublishService);
+        }
 
-        supportedProviderServices = ImmutableClassToInstanceMap.<BindingAwareService> builder()
-                .putAll(supportedConsumerServices)
-                .put(NotificationProviderService.class, getRoot()) //
-                .put(DataProviderService.class, getRoot()) //
-                .put(RpcProviderRegistry.class, getRoot()) //
-                .put(MountProviderService.class, mountManager).build();
+        supportedProviderServices = provBuilder.build();
     }
 
     @Override
-    public ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx) {
+    public ConsumerContext registerConsumer(final BindingAwareConsumer consumer, final BundleContext ctx) {
+        return registerConsumer(consumer);
+    }
+
+    @Override
+    public ProviderContext registerProvider(final BindingAwareProvider provider, final BundleContext ctx) {
+        return registerProvider(provider);
+    }
+
+    @Override
+    public ConsumerContext registerConsumer(final BindingAwareConsumer consumer) {
         checkState(supportedConsumerServices != null, "Broker is not initialized.");
         return BindingContextUtils.createConsumerContextAndInitialize(consumer, supportedConsumerServices);
     }
 
     @Override
-    public ProviderContext registerProvider(BindingAwareProvider provider, BundleContext ctx) {
+    public ProviderContext registerProvider(final BindingAwareProvider provider) {
         checkState(supportedProviderServices != null, "Broker is not initialized.");
         return BindingContextUtils.createProviderContextAndInitialize(provider, supportedProviderServices);
     }
@@ -144,36 +164,37 @@ public class RootBindingAwareBroker implements //
     public void close() throws Exception {
         // FIXME: Close all sessions
     }
-    
+
     @Override
-    public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type, T implementation)
-            throws IllegalStateException {
+    public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type,
+            final T implementation) throws IllegalStateException {
         return getRoot().addRoutedRpcImplementation(type, implementation);
     }
-    
+
     @Override
-    public <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
+    public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type, final T implementation)
             throws IllegalStateException {
         return getRoot().addRpcImplementation(type, implementation);
     }
-    
+
     @Override
-    public <T extends RpcService> T getRpcService(Class<T> module) {
+    public <T extends RpcService> T getRpcService(final Class<T> module) {
         return getRoot().getRpcService(module);
     }
+
     @Override
     public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
-            L arg0) {
+            final L arg0) {
         return getRoot().registerRouteChangeListener(arg0);
     }
-    
 
     public class RootSalInstance extends
-            AbstractBindingSalProviderInstance<DataProviderService, NotificationProviderService, RpcProviderRegistry> {
+            AbstractBindingSalProviderInstance<NotificationProviderService, RpcProviderRegistry> {
 
-        public RootSalInstance(RpcProviderRegistry rpcRegistry, NotificationProviderService notificationBroker,
-                DataProviderService dataBroker) {
-            super(rpcRegistry, notificationBroker, dataBroker);
+        public RootSalInstance(final RpcProviderRegistry rpcRegistry,
+                final NotificationProviderService notificationBroker) {
+            super(rpcRegistry, notificationBroker);
         }
     }
+
 }