*/
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;
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;
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,
+@Deprecated(forRemoval = true)
+public class RootBindingAwareBroker implements Mutable, Identifiable<String>, BindingAwareBroker, AutoCloseable,
RpcProviderRegistry {
- private final static Logger LOG = LoggerFactory.getLogger(RootBindingAwareBroker.class);
+ private static final Logger LOG = LoggerFactory.getLogger(RootBindingAwareBroker.class);
RootSalInstance controllerRoot;
private NotificationProviderService notificationBroker;
- private DataProviderService dataBroker;
-
- private MountPointManagerImpl mountManager;
+ private NotificationPublishService notificationPublishService;
- 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;
}
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;
}
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 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, final BundleContext ctx) {
+ return registerProvider(provider);
+ }
+
+ @Override
+ public ProviderContext registerProvider(final BindingAwareProvider provider) {
checkState(supportedProviderServices != null, "Broker is not initialized.");
return BindingContextUtils.createProviderContextAndInitialize(provider, supportedProviderServices);
}
@Override
- public void close() throws Exception {
+ public void close() {
// 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) {
- return getRoot().registerRouteChangeListener(arg0);
+ public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L>
+ registerRouteChangeListener(final L listener) {
+ return getRoot().registerRouteChangeListener(listener);
}
+ public static class RootSalInstance extends
+ AbstractBindingSalProviderInstance<NotificationProviderService, RpcProviderRegistry> {
- public class RootSalInstance extends
- AbstractBindingSalProviderInstance<DataProviderService, 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);
}
}
}