From 3e5b44dbf2576fb9b2af1a36f927555eb7ed5990 Mon Sep 17 00:00:00 2001 From: Tony Tkacik Date: Thu, 19 Jun 2014 16:38:21 +0200 Subject: [PATCH] Bug 629: Make BindingDataBroker to be visible. Inroduced support for injecting and retrieving new BindingDataBroker via config-subsystem, OSGI. Note: This patch does not provide access to BindingDataBroker is still not available via Consumer/Provider context. Change-Id: Iaa7e65aeeb873c38fded2fecb45e2f0dca1e7714 Signed-off-by: Tony Tkacik --- .../configuration/initial/01-md-sal.xml | 22 ++++++ .../md/sal/binding/api/BindingDataBroker.java | 2 +- .../md/sal/binding/api/BindingService.java | 30 ++++++++ .../md-sal/sal-binding-broker/pom.xml | 2 +- .../BindingAsyncDataBrokerImplModule.java | 75 +++++++++++++++++++ ...ndingAsyncDataBrokerImplModuleFactory.java | 37 +++++++++ .../binding/impl/BindingBrokerImplModule.java | 19 ++--- .../codegen/impl/RuntimeCodeGenerator.xtend | 9 ++- .../binding/impl/RootBindingAwareBroker.java | 74 ++++++++++-------- .../opendaylight-binding-broker-impl.yang | 51 +++++++++---- .../binding/test/util/BindingTestContext.java | 2 +- .../yang/opendaylight-md-sal-binding.yang | 5 ++ 12 files changed, 264 insertions(+), 64 deletions(-) create mode 100644 opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingService.java create mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingAsyncDataBrokerImplModule.java create mode 100644 opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingAsyncDataBrokerImplModuleFactory.java diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml index d872bfd47b..8b07ce3a33 100644 --- a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml +++ b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml @@ -68,6 +68,20 @@ runtime-mapping-singleton + + prefix:binding-forwarded-data-broker + binding-async-data-broker + + + dom:dom-broker-osgi-registry + dom-broker + + + binding:binding-dom-mapping-service + runtime-mapping-singleton + + + @@ -122,6 +136,14 @@ + + binding:binding-async-data-broker + + binding-data-broker + /modules/module[type='binding-forwarded-data-broker'][name='binding-async-data-broker'] + + + dom:dom-async-data-broker diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataBroker.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataBroker.java index c6a9efe21c..7eee5c8b62 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataBroker.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataBroker.java @@ -13,7 +13,7 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public interface BindingDataBroker extends AsyncDataBroker, DataObject, BindingDataChangeListener>{ +public interface BindingDataBroker extends AsyncDataBroker, DataObject, BindingDataChangeListener>, BindingService { @Override BindingDataReadTransaction newReadOnlyTransaction(); diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingService.java new file mode 100644 index 0000000000..ccce73c7d7 --- /dev/null +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingService.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.md.sal.binding.api; + +import org.opendaylight.controller.sal.binding.api.BindingAwareService; + +/** + * + * Marker interface for MD-SAL services which are available for users of MD-SAL. + * + * BindingService is marker interface for infrastructure services provided by + * the SAL. These services may be session-specific, and wrapped by custom + * delegator patterns in order to introduce additional semantics / checks + * to the system. + * + * This interface extends {@link BindingAwareService}, order to be make + * new services available via + * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext} + * and via + * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext} + * + */ +public interface BindingService extends BindingAwareService { + +} diff --git a/opendaylight/md-sal/sal-binding-broker/pom.xml b/opendaylight/md-sal/sal-binding-broker/pom.xml index 2470ba5133..7fc467670d 100644 --- a/opendaylight/md-sal/sal-binding-broker/pom.xml +++ b/opendaylight/md-sal/sal-binding-broker/pom.xml @@ -142,7 +142,7 @@ org.opendaylight.controller.md.sal.binding.impl, org.opendaylight.controller.sal.binding.osgi.*, - org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.binding.impl.rev131028 + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.binding.impl.rev131028.* diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingAsyncDataBrokerImplModule.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingAsyncDataBrokerImplModule.java new file mode 100644 index 0000000000..17cd67a857 --- /dev/null +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingAsyncDataBrokerImplModule.java @@ -0,0 +1,75 @@ +package org.opendaylight.controller.config.yang.md.sal.binding.impl; + +import java.util.Collection; +import java.util.Collections; + +import org.opendaylight.controller.md.sal.binding.impl.ForwardedBindingDataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.sal.core.api.Broker; +import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; +import org.opendaylight.controller.sal.core.api.Provider; +import org.opendaylight.controller.sal.core.api.model.SchemaService; +import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService; +import org.osgi.framework.BundleContext; + +public class BindingAsyncDataBrokerImplModule extends + org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingAsyncDataBrokerImplModule implements + Provider { + private BundleContext bundleContext; + + public BindingAsyncDataBrokerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, + final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public BindingAsyncDataBrokerImplModule( + final org.opendaylight.controller.config.api.ModuleIdentifier identifier, + final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + final org.opendaylight.controller.config.yang.md.sal.binding.impl.BindingAsyncDataBrokerImplModule oldModule, + final java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + Broker domBroker = getDomAsyncBrokerDependency(); + BindingIndependentMappingService mappingService = getBindingMappingServiceDependency(); + + // FIXME: Switch this to DOM Broker registration which would not require + // BundleContext when API are updated. + ProviderSession session = domBroker.registerProvider(this, getBundleContext()); + DOMDataBroker domDataBroker = session.getService(DOMDataBroker.class); + SchemaService schemaService = session.getService(SchemaService.class); + return new ForwardedBindingDataBroker(domDataBroker, mappingService, schemaService); + } + + // FIXME: Remove this when DOM Broker registration would not require + // BundleContext + @Deprecated + private BundleContext getBundleContext() { + return bundleContext; + } + + // FIXME: Remove this when DOM Broker registration would not require + // BundleContext + @Deprecated + void setBundleContext(final BundleContext bundleContext) { + this.bundleContext = bundleContext; + } + + @Override + public Collection getProviderFunctionality() { + return Collections.emptySet(); + } + + @Override + public void onSessionInitiated(final ProviderSession arg0) { + // intentional NOOP + } + +} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingAsyncDataBrokerImplModuleFactory.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingAsyncDataBrokerImplModuleFactory.java new file mode 100644 index 0000000000..763e6ad3ca --- /dev/null +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingAsyncDataBrokerImplModuleFactory.java @@ -0,0 +1,37 @@ +/* +* Generated file +* +* Generated from: yang module name: opendaylight-sal-binding-broker-impl yang module local name: binding-forwarded-data-broker +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Fri May 16 17:18:18 CEST 2014 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.controller.config.yang.md.sal.binding.impl; + +import org.opendaylight.controller.config.api.DependencyResolver; +import org.osgi.framework.BundleContext; + +public class BindingAsyncDataBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingAsyncDataBrokerImplModuleFactory { + + + + + @Override + public BindingAsyncDataBrokerImplModule instantiateModule(final String instanceName, + final DependencyResolver dependencyResolver, final BindingAsyncDataBrokerImplModule oldModule, + final AutoCloseable oldInstance, final BundleContext bundleContext) { + BindingAsyncDataBrokerImplModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule, oldInstance, bundleContext); + module.setBundleContext(bundleContext); + return module; + } + + @Override + public BindingAsyncDataBrokerImplModule instantiateModule(final String instanceName, + final DependencyResolver dependencyResolver, final BundleContext bundleContext) { + // TODO Auto-generated method stub + BindingAsyncDataBrokerImplModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext); + module.setBundleContext(bundleContext); + return module; + } +} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModule.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModule.java index 44a508c0a0..188272fb60 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModule.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModule.java @@ -31,14 +31,14 @@ public final class BindingBrokerImplModule extends private BundleContext bundleContext; - public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, - org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + public BindingBrokerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, + final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); } - public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, - org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, - BindingBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) { + public BindingBrokerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, + final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + final BindingBrokerImplModule oldModule, final java.lang.AutoCloseable oldInstance) { super(identifier, dependencyResolver, oldModule, oldInstance); } @@ -63,23 +63,24 @@ public final class BindingBrokerImplModule extends private RootBindingAwareBroker createStandaloneBroker() { RootBindingAwareBroker broker = new RootBindingAwareBroker(getIdentifier().getInstanceName()); - broker.setDataBroker(getDataBrokerDependency()); + broker.setLegacyDataBroker(getDataBrokerDependency()); broker.setNotificationBroker(getNotificationServiceDependency()); broker.setRpcBroker(new RpcProviderRegistryImpl(broker.getIdentifier())); + // FIXME: Also set Async Data Broker return broker; } private RootBindingAwareBroker createForwardedBroker() { DomForwardedBindingBrokerImpl broker = new DomForwardedBindingBrokerImpl(getIdentifier().getInstanceName()); - broker.setDataBroker(getDataBrokerDependency()); + broker.setLegacyDataBroker(getDataBrokerDependency()); broker.setNotificationBroker(getNotificationServiceDependency()); broker.setRpcBroker(new RpcProviderRegistryImpl(broker.getIdentifier())); broker.getMountManager().setDataCommitExecutor(SingletonHolder.getDefaultCommitExecutor()); broker.getMountManager().setNotificationExecutor(SingletonHolder.getDefaultNotificationExecutor()); - + // FIXME: Also set Async Data Broker DomForwardingUtils.reuseForwardingFrom(broker, broker.getDataBroker()); broker.startForwarding(); return broker; @@ -89,7 +90,7 @@ public final class BindingBrokerImplModule extends return bundleContext; } - public void setBundleContext(BundleContext bundleContext) { + public void setBundleContext(final BundleContext bundleContext) { this.bundleContext = bundleContext; } } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend index 3fef544f81..00c9f1eb91 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend @@ -16,6 +16,7 @@ import org.opendaylight.yangtools.yang.binding.util.BindingReflections import org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils import static extension org.opendaylight.controller.sal.binding.codegen.RuntimeCodeSpecification.* +import org.opendaylight.yangtools.yang.binding.RpcService class RuntimeCodeGenerator extends AbstractRuntimeCodeGenerator { @@ -28,7 +29,7 @@ class RuntimeCodeGenerator extends AbstractRuntimeCodeGenerator { val proxyName = iface.directProxyName; val potentialClass = ClassLoaderUtils.tryToLoadClassWithTCCL(proxyName) if(potentialClass != null) { - return potentialClass.newInstance; + return potentialClass.newInstance as RpcService; } val supertype = iface.asCtClass val createdCls = createClass(iface.directProxyName, supertype) [ @@ -53,7 +54,7 @@ class RuntimeCodeGenerator extends AbstractRuntimeCodeGenerator { ''' ] ] - return createdCls.toClass(iface.classLoader).newInstance + return createdCls.toClass(iface.classLoader).newInstance as RpcService ] } @@ -63,7 +64,7 @@ class RuntimeCodeGenerator extends AbstractRuntimeCodeGenerator { val routerName = iface.routerName; val potentialClass = ClassLoaderUtils.tryToLoadClassWithTCCL(routerName) if(potentialClass != null) { - return potentialClass.newInstance; + return potentialClass.newInstance as RpcService; } val targetCls = createClass(iface.routerName, supertype) [ @@ -106,7 +107,7 @@ class RuntimeCodeGenerator extends AbstractRuntimeCodeGenerator { ''' ] ] - return targetCls.toClass(iface.classLoader,iface.protectionDomain).newInstance + return targetCls.toClass(iface.classLoader,iface.protectionDomain).newInstance as RpcService ]; } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java index 75d44db9d1..8acad1b2d7 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java @@ -7,7 +7,9 @@ */ package org.opendaylight.controller.sal.binding.impl; -import com.google.common.collect.ImmutableClassToInstanceMap; +import static com.google.common.base.Preconditions.checkState; + +import org.opendaylight.controller.md.sal.binding.api.BindingDataBroker; 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; @@ -32,13 +34,13 @@ 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; + +import com.google.common.collect.ImmutableClassToInstanceMap; public class RootBindingAwareBroker implements // Mutable, // Identifiable, // - BindingAwareBroker, AutoCloseable, - RpcProviderRegistry { + BindingAwareBroker, AutoCloseable, RpcProviderRegistry { private final static Logger LOG = LoggerFactory.getLogger(RootBindingAwareBroker.class); @@ -50,7 +52,9 @@ public class RootBindingAwareBroker implements // private NotificationProviderService notificationBroker; - private DataProviderService dataBroker; + private DataProviderService legacyDataBroker; + + private BindingDataBroker dataBroker; private MountPointManagerImpl mountManager; @@ -58,7 +62,7 @@ public class RootBindingAwareBroker implements // return mountManager; } - public void setMountManager(MountPointManagerImpl mountManager) { + public void setMountManager(final MountPointManagerImpl mountManager) { this.mountManager = mountManager; } @@ -66,11 +70,12 @@ public class RootBindingAwareBroker implements // private ImmutableClassToInstanceMap supportedProviderServices; - public RootBindingAwareBroker(String instanceName) { + public RootBindingAwareBroker(final String instanceName) { this.identifier = instanceName; mountManager = new MountPointManagerImpl(); } + @Override public String getIdentifier() { return identifier; } @@ -80,7 +85,7 @@ public class RootBindingAwareBroker implements // } public DataProviderService getDataBroker() { - return this.dataBroker; + return this.legacyDataBroker; } public NotificationProviderService getNotificationBroker() { @@ -95,16 +100,16 @@ public class RootBindingAwareBroker implements // return rpcBroker; } - public void setRpcBroker(RpcProviderRegistry rpcBroker) { + 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 setLegacyDataBroker(final DataProviderService dataBroker) { + this.legacyDataBroker = dataBroker; } public void start() { @@ -113,29 +118,30 @@ public class RootBindingAwareBroker implements // controllerRoot = new RootSalInstance(getRpcProviderRegistry(), getNotificationBroker(), getDataBroker()); + ImmutableClassToInstanceMap.Builder consBuilder = ImmutableClassToInstanceMap.builder(); - supportedConsumerServices = ImmutableClassToInstanceMap. 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(DataBrokerService.class, getRoot()); + consBuilder.put(RpcConsumerRegistry.class, getRoot()); + if(dataBroker != null) { + consBuilder.put(BindingDataBroker.class, dataBroker); + } + consBuilder.put(MountService.class, mountManager).build(); + supportedConsumerServices = consBuilder.build(); supportedProviderServices = ImmutableClassToInstanceMap. builder() - .putAll(supportedConsumerServices) - .put(NotificationProviderService.class, getRoot()) // - .put(DataProviderService.class, getRoot()) // - .put(RpcProviderRegistry.class, getRoot()) // + .putAll(supportedConsumerServices).put(NotificationProviderService.class, getRoot()) + .put(DataProviderService.class, getRoot()).put(RpcProviderRegistry.class, getRoot()) .put(MountProviderService.class, mountManager).build(); } @Override - public ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx) { + public ConsumerContext registerConsumer(final BindingAwareConsumer consumer, final BundleContext ctx) { 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) { checkState(supportedProviderServices != null, "Broker is not initialized."); return BindingContextUtils.createProviderContextAndInitialize(provider, supportedProviderServices); } @@ -146,34 +152,38 @@ public class RootBindingAwareBroker implements // } @Override - public RoutedRpcRegistration addRoutedRpcImplementation(Class type, T implementation) - throws IllegalStateException { + public RoutedRpcRegistration addRoutedRpcImplementation(final Class type, + final T implementation) throws IllegalStateException { return getRoot().addRoutedRpcImplementation(type, implementation); } @Override - public RpcRegistration addRpcImplementation(Class type, T implementation) + public RpcRegistration addRpcImplementation(final Class type, final T implementation) throws IllegalStateException { return getRoot().addRpcImplementation(type, implementation); } @Override - public T getRpcService(Class module) { + public T getRpcService(final Class module) { return getRoot().getRpcService(module); } + @Override public >> ListenerRegistration registerRouteChangeListener( - L arg0) { + final L arg0) { return getRoot().registerRouteChangeListener(arg0); } - public class RootSalInstance extends AbstractBindingSalProviderInstance { - public RootSalInstance(RpcProviderRegistry rpcRegistry, NotificationProviderService notificationBroker, - DataProviderService dataBroker) { + public RootSalInstance(final RpcProviderRegistry rpcRegistry, + final NotificationProviderService notificationBroker, final DataProviderService dataBroker) { super(rpcRegistry, notificationBroker, dataBroker); } } + + public void setDataBroker(final BindingDataBroker asyncDataBroker) { + dataBroker = asyncDataBroker; + } } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang b/opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang index 428025a58d..4456dea77f 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang +++ b/opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang @@ -42,6 +42,12 @@ module opendaylight-sal-binding-broker-impl { config:provided-service sal:binding-data-consumer-broker; config:java-name-prefix ForwardedCompatibleDataBrokerImpl; } + + identity binding-forwarded-data-broker { + base config:module-type; + config:provided-service sal:binding-async-data-broker; + config:java-name-prefix BindingAsyncDataBrokerImpl; + } identity binding-rpc-broker { base config:module-type; @@ -62,6 +68,26 @@ module opendaylight-sal-binding-broker-impl { config:java-name-prefix RuntimeMapping; } + grouping dom-forwarding-component { + container dom-async-broker { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity dom:dom-broker-osgi-registry; + } + } + } + + container binding-mapping-service { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity binding-dom-mapping-service; + } + } + } + } + augment "/config:modules/config:module/config:configuration" { case binding-broker-impl { when "/config:modules/config:module/config:type = 'binding-broker-impl'"; @@ -123,22 +149,15 @@ module opendaylight-sal-binding-broker-impl { case binding-data-compatible-broker { when "/config:modules/config:module/config:type = 'binding-data-compatible-broker'"; - container dom-async-broker { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity dom:dom-broker-osgi-registry; - } - } - } - - container binding-mapping-service { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity binding-dom-mapping-service; - } - } + uses dom-forwarding-component; + } + } + + augment "/config:modules/config:module/config:configuration" { + case binding-forwarded-data-broker { + when "/config:modules/config:module/config:type = 'binding-forwarded-data-broker'"; + container binding-forwarded-data-broker { + uses dom-forwarding-component; } } } diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java index 689d48e8b6..623b2fdd63 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java @@ -184,7 +184,7 @@ public class BindingTestContext implements AutoCloseable { baBrokerImpl.getMountManager().setDataCommitExecutor(executor); baBrokerImpl.getMountManager().setNotificationExecutor(executor); baBrokerImpl.setRpcBroker(new RpcProviderRegistryImpl("test")); - baBrokerImpl.setDataBroker(baData); + baBrokerImpl.setLegacyDataBroker(baData); baBrokerImpl.setNotificationBroker(baNotifyImpl); baBrokerImpl.start(); } diff --git a/opendaylight/md-sal/sal-binding-config/src/main/yang/opendaylight-md-sal-binding.yang b/opendaylight/md-sal/sal-binding-config/src/main/yang/opendaylight-md-sal-binding.yang index 38f0da3ccc..4a2ec8a063 100644 --- a/opendaylight/md-sal/sal-binding-config/src/main/yang/opendaylight-md-sal-binding.yang +++ b/opendaylight/md-sal/sal-binding-config/src/main/yang/opendaylight-md-sal-binding.yang @@ -22,6 +22,11 @@ module opendaylight-md-sal-binding { base "config:service-type"; config:java-class "org.opendaylight.controller.sal.binding.api.data.DataProviderService"; } + + identity binding-async-data-broker { + base "config:service-type"; + config:java-class "org.opendaylight.controller.md.sal.binding.api.BindingDataBroker"; + } identity binding-data-consumer-broker { base "config:service-type"; -- 2.36.6