Bug 2364: Migrated Binding MD-SAL to not use composites nodes 61/16261/4
authorTony Tkacik <ttkacik@cisco.com>
Sun, 8 Mar 2015 15:30:27 +0000 (16:30 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Tue, 10 Mar 2015 15:18:37 +0000 (16:18 +0100)
Bidning MD-SAL is fully migrated to be adapter on top
of NormalizedNode MD-SAL. This migration once all legacy
classes are removed will provide easier-to-read more
maintanable code of Binding MD-SAL.

Change-Id: I1df6cda4bd6035ac5e01e1285f8aab4201dcc86d
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
73 files changed:
opendaylight/md-sal/md-sal-config/src/main/resources/initial/01-md-sal.xml
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/MountPoint.java
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/MountPointService.java
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcConsumerRegistry.java
opendaylight/md-sal/sal-binding-broker/pom.xml
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingAsyncDataBrokerImplModule.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModule.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/ForwardedCompatibleDataBrokerImplModule.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/CompositeRoutedRpcRegistration.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/DelegatedRootRpcRegistration.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceAdapter.java [moved from opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/compat/HeliumNotificationProviderServiceAdapter.java with 97% similarity]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationServiceAdapter.java [moved from opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/compat/HeliumNotificationServiceAdapter.java with 96% similarity]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumRpcProviderRegistry.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenDataBrokerAdapter.java [moved from opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java with 86% similarity]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenDataChangeEvent.java [moved from opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LegacyDataChangeEvent.java with 96% similarity]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenMountInstanceAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenMountPointServiceAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenMountProvisionServiceAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterBuilder.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterLoader.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointListenerAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcAdapterRegistration.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcProviderServiceAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcServiceAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingMountPointAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcAdapterRegistration.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcImplementationAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBindingDataBroker.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedNotificationPublishService.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedNotificationService.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedContainerNode.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedDOMRpcResult.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterBuilder.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterLoader.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/MountPointManagerImpl.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingDomConnectorDeployer.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingToDomCommitHandler.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingToDomTransaction.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingCommitHandler.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingNotificationForwarder.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingRpcForwarder.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingRpcForwardingManager.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingTransaction.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/RpcInvocationStrategy.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBindingBrokerImpl.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBroker.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardingUtils.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/BackwardsCompatibleNotificationBrokerTest.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/ForwardedBackwardsCompatibleDataBrokerTest.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/RpcProviderRegistryTest.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/DataBrokerTestCustomizer.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/impl/connect/dom/RpcInvocationStrategyTest.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerMountPointTest.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/CrossBrokerRpcTest.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceTest.java
opendaylight/md-sal/sal-binding-it/src/test/resources/controller.xml
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcIdentifier.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMService.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMRpcRoutingTableEntry.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRoutingTable.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/GlobalDOMRpcRoutingTableEntry.java
opendaylight/md-sal/samples/toaster-it/src/test/resources/controller.xml

index 8b64527..8d5d525 100644 (file)
@@ -15,7 +15,6 @@
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:schema-service-singleton</type>
                     <name>yang-schema-service</name>
                 </module>
-
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
                     <name>runtime-mapping-singleton</name>
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
                     <name>binding-broker-impl</name>
-                    <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
-                        <name>binding-notification-broker</name>
-                    </notification-service>
-                    <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
-                        <name>binding-data-broker</name>
-                    </data-broker>
-                    <root-data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
-                        <name>binding-data-broker</name>
-                    </root-data-broker>
+                    <binding-broker-impl xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                        <binding-mapping-service>
+                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
+                            <name>runtime-mapping-singleton</name>
+                        </binding-mapping-service>
+                        <dom-async-broker>
+                            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
+                            <name>dom-broker</name>
+                        </dom-async-broker>
+                        <notification-service>
+                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
+                            <name>binding-notification-broker</name>
+                        </notification-service>
+                        <data-broker>
+                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
+                            <name>binding-data-broker</name>
+                        </data-broker>
+                        <root-data-broker>
+                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+                            <name>binding-data-broker</name>
+                        </root-data-broker>
+                    </binding-broker-impl>
                 </module>
 
 
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-compatible-broker</type>
                     <name>inmemory-binding-data-broker</name>
-                    <dom-async-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                        <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-                        <name>dom-broker</name>
-                    </dom-async-broker>
-                    <binding-mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
-                        <name>runtime-mapping-singleton</name>
-                    </binding-mapping-service>
+                    <binding-data-compatible-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                        <data-broker>
+                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+                            <name>binding-data-broker</name>
+                        </data-broker>
+                    </binding-data-compatible-broker>
                 </module>
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-forwarded-data-broker</type>
                             <provider>/modules/module[type='pingpong-data-broker'][name='pingpong-data-broker']</provider>
                         </instance>
                     </service>
+
             </services>
         </data>
     </configuration>
index ee0a113..e8bd753 100644 (file)
@@ -7,14 +7,12 @@
  */
 package org.opendaylight.controller.md.sal.binding.api;
 
-import org.opendaylight.controller.sal.binding.api.BindingAwareService;
+import com.google.common.base.Optional;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import com.google.common.base.Optional;
-
 public interface MountPoint extends Identifiable<InstanceIdentifier<?>>{
 
-    <T extends BindingAwareService> Optional<T> getService(Class<T> service);
+    <T extends BindingService> Optional<T> getService(Class<T> service);
 
 }
index dd3a37e..0558327 100644 (file)
@@ -7,14 +7,12 @@
  */
 package org.opendaylight.controller.md.sal.binding.api;
 
+import com.google.common.base.Optional;
 import java.util.EventListener;
-
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import com.google.common.base.Optional;
-
-public interface MountPointService {
+public interface MountPointService extends BindingService {
 
     Optional<MountPoint> getMountPoint(InstanceIdentifier<?> mountPoint);
 
index 615acd3..0c5e764 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.sal.binding.api;
 
+import org.opendaylight.controller.md.sal.binding.api.BindingService;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 
 /**
@@ -16,7 +17,7 @@ import org.opendaylight.yangtools.yang.binding.RpcService;
  * RPC implementations are registered using the {@link RpcProviderRegistry}.
  *
  */
-public interface RpcConsumerRegistry extends BindingAwareService {
+public interface RpcConsumerRegistry extends BindingAwareService, BindingService {
     /**
      * Returns an implementation of a requested RPC service.
      *
index 0c55db1..e95b118 100644 (file)
                             org.opendaylight.controller.sal.binding.codegen,
                             org.opendaylight.controller.sal.binding.codegen.*,
                             org.opendaylight.controller.md.sal.binding.impl,
+                            org.opendaylight.controller.md.sal.binding.compat,
+                            org.opendaylight.controller.md.sal.binding.spi,
               <!--org.opendaylight.controller.sal.binding.dom.*,-->
               org.opendaylight.controller.sal.binding.osgi.*,
                             org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.binding.impl.rev131028.*
index d0d6821..2503d3d 100644 (file)
@@ -3,7 +3,6 @@ package org.opendaylight.controller.config.yang.md.sal.binding.impl;
 import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
 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.model.SchemaService;
 
 public class BindingAsyncDataBrokerImplModule extends
         org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingAsyncDataBrokerImplModule {
@@ -30,8 +29,7 @@ public class BindingAsyncDataBrokerImplModule extends
     public java.lang.AutoCloseable createInstance() {
         final BindingToNormalizedNodeCodec mappingService = getBindingMappingServiceDependency();
         final DOMDataBroker domDataBroker = getDomAsyncBrokerDependency();
-        final SchemaService schemaService = getSchemaServiceDependency();
-        return new ForwardedBindingDataBroker(domDataBroker, mappingService, schemaService);
+        return new ForwardedBindingDataBroker(domDataBroker, mappingService);
     }
 
 }
index 61e7a2e..f74faa3 100644 (file)
  */
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
 
-import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.controller.md.sal.binding.compat.HeliumRpcProviderRegistry;
+import org.opendaylight.controller.md.sal.binding.compat.HydrogenMountProvisionServiceAdapter;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMMountPointServiceAdapter;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcServiceAdapter;
+import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
 import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
-import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;
-import org.opendaylight.controller.sal.binding.impl.forward.DomForwardedBindingBrokerImpl;
-import org.opendaylight.controller.sal.binding.impl.forward.DomForwardingUtils;
+import org.opendaylight.controller.sal.core.api.Broker;
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
 
 /**
 *
@@ -45,41 +55,60 @@ public final class BindingBrokerImplModule extends
     }
 
     @Override
-    public java.lang.AutoCloseable createInstance() {
+    public RootBindingAwareBroker createInstance() {
+        final Broker domBroker = getDomAsyncBrokerDependency();
+        final BindingToNormalizedNodeCodec codec = getBindingMappingServiceDependency();
+        final ProviderSession session = domBroker.registerProvider(new DummyDOMProvider());
 
-        RootBindingAwareBroker broker;
-        if (DomForwardingUtils.isDomForwardedBroker(getDataBrokerDependency())) {
-            broker = createForwardedBroker();
-        } else {
-            broker = createStandaloneBroker();
-        }
-        broker.start();
-        return broker;
-    }
-
-    private RootBindingAwareBroker createStandaloneBroker() {
-        RootBindingAwareBroker broker = new RootBindingAwareBroker(getIdentifier().getInstanceName());
+        final MountPointService mount = createMountPointAdapter(codec,session);
+        final BindingDOMRpcServiceAdapter rpcConsumer = createRpcConsumer(codec,session);
+        final BindingDOMRpcProviderServiceAdapter rpcProvider = createRpcProvider(codec,session);
+        final RootBindingAwareBroker broker = new RootBindingAwareBroker(getIdentifier().getInstanceName());
+        final RpcProviderRegistry heliumRpcBroker = new HeliumRpcProviderRegistry(rpcConsumer, rpcProvider);
+        final MountProviderService legacyMount = createLegacyMountPointService(mount);
 
         broker.setLegacyDataBroker(getDataBrokerDependency());
         broker.setNotificationBroker(getNotificationServiceDependency());
-        broker.setRpcBroker(new RpcProviderRegistryImpl(broker.getIdentifier()));
+        broker.setRpcBroker(heliumRpcBroker);
         broker.setDataBroker(getRootDataBrokerDependency());
+        broker.setMountService(mount);
+        broker.setLegacyMountManager(legacyMount);
+        broker.start();
         return broker;
     }
 
-    private RootBindingAwareBroker createForwardedBroker() {
-        DomForwardedBindingBrokerImpl broker = new DomForwardedBindingBrokerImpl(getIdentifier().getInstanceName());
 
-        broker.setLegacyDataBroker(getDataBrokerDependency());
-        broker.setNotificationBroker(getNotificationServiceDependency());
-        broker.setRpcBroker(new RpcProviderRegistryImpl(broker.getIdentifier()));
+    @SuppressWarnings("deprecation")
+    private MountProviderService createLegacyMountPointService(final MountPointService service) {
+        if(service != null) {
+            return new HydrogenMountProvisionServiceAdapter(service);
+        }
+        return null;
+    }
 
-        broker.getMountManager().setDataCommitExecutor(SingletonHolder.getDefaultCommitExecutor());
-        broker.getMountManager().setNotificationExecutor(SingletonHolder.getDefaultNotificationExecutor());
+    private BindingDOMRpcProviderServiceAdapter createRpcProvider(final BindingToNormalizedNodeCodec codec,
+            final ProviderSession session) {
+        final DOMRpcProviderService domService = session.getService(DOMRpcProviderService.class);
+        if(domService != null) {
+            return new BindingDOMRpcProviderServiceAdapter(domService, codec);
+        }
+        return null;
+    }
 
-        broker.setDataBroker(getRootDataBrokerDependency());
-        DomForwardingUtils.reuseForwardingFrom(broker, broker.getDataBroker());
-        broker.startForwarding();
-        return broker;
+    private BindingDOMRpcServiceAdapter createRpcConsumer(final BindingToNormalizedNodeCodec codec, final ProviderSession session) {
+        final DOMRpcService domService = session.getService(DOMRpcService.class);
+        if(domService != null) {
+            return new BindingDOMRpcServiceAdapter(domService, codec);
+        }
+        return null;
     }
+
+    private MountPointService createMountPointAdapter(final BindingToNormalizedNodeCodec codec, final ProviderSession session) {
+        final DOMMountPointService domService = session.getService(DOMMountPointService.class);
+        if(domService != null) {
+            return new BindingDOMMountPointServiceAdapter(domService, codec);
+        }
+        return null;
+    }
+
 }
index 2bc673a..6f03c15 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2015 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,
@@ -7,22 +7,17 @@
  */
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
 
-import com.google.common.util.concurrent.ListeningExecutorService;
+import org.opendaylight.controller.md.sal.binding.compat.HydrogenDataBrokerAdapter;
+
 import java.util.Collection;
 import java.util.Collections;
-import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.md.sal.binding.impl.ForwardedBackwardsCompatibleDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
-import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingDomConnectorDeployer;
-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;
 
 /**
 *
 */
+@Deprecated
 public final class ForwardedCompatibleDataBrokerImplModule extends
         org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractForwardedCompatibleDataBrokerImplModule
         implements Provider {
@@ -43,23 +38,11 @@ public final class ForwardedCompatibleDataBrokerImplModule extends
 
     @Override
     protected void customValidation() {
-        // Add custom validation for module attributes here.
     }
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        ListeningExecutorService listeningExecutor = SingletonHolder.getDefaultCommitExecutor();
-        BindingToNormalizedNodeCodec mappingService = getBindingMappingServiceDependency();
-
-        Broker domBroker = getDomAsyncBrokerDependency();
-        ProviderSession session = domBroker.registerProvider(this, null);
-        DOMDataBroker domDataBroker = session.getService(DOMDataBroker.class);
-        SchemaService schemaService = session.getService(SchemaService.class);
-        ForwardedBackwardsCompatibleDataBroker dataBroker = new ForwardedBackwardsCompatibleDataBroker(domDataBroker,
-                mappingService, schemaService,listeningExecutor);
-
-        dataBroker.setConnector(BindingDomConnectorDeployer.createConnector(mappingService.getLegacy()));
-        dataBroker.setDomProviderContext(session);
+        final HydrogenDataBrokerAdapter dataBroker = new HydrogenDataBrokerAdapter(getDataBrokerDependency());
         return dataBroker;
     }
 
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/CompositeRoutedRpcRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/CompositeRoutedRpcRegistration.java
new file mode 100644 (file)
index 0000000..bb6c2e7
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015 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.compat;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableSet;
+import java.util.HashMap;
+import java.util.Map;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+final class CompositeRoutedRpcRegistration<T extends RpcService> implements RoutedRpcRegistration<T> {
+
+    private final Class<T> type;
+    private final T instance;
+    private final BindingDOMRpcProviderServiceAdapter adapter;
+    private final Map<InstanceIdentifier<?>, ObjectRegistration<T>> registrations = new HashMap<>(2);
+
+    CompositeRoutedRpcRegistration(final Class<T> type, final T impl, final BindingDOMRpcProviderServiceAdapter providerAdapter) {
+        this.type = type;
+        this.instance = impl;
+        this.adapter = providerAdapter;
+    }
+
+    @Override
+    public Class<T> getServiceType() {
+        return type;
+    }
+
+    @Override
+    public T getInstance() {
+        return instance;
+    }
+
+    @Deprecated
+    @Override
+    public void registerInstance(final Class<? extends BaseIdentity> context, final InstanceIdentifier<?> path) {
+        registerPath(context, path);
+    }
+
+    @Override
+    public synchronized void registerPath(final Class<? extends BaseIdentity> context, final InstanceIdentifier<?> path) {
+        if(!registrations.containsKey(path)) {
+            registrations.put(path, adapter.registerRpcImplementation(type, instance, ImmutableSet.<InstanceIdentifier<?>>of(path)));
+        }
+    }
+
+
+    @Override
+    @Deprecated
+    public void unregisterInstance(final Class<? extends BaseIdentity> context, final InstanceIdentifier<?> path) {
+        unregisterPath(context, path);
+    }
+
+    @Override
+    public synchronized  void unregisterPath(final Class<? extends BaseIdentity> context, final InstanceIdentifier<?> path) {
+        final ObjectRegistration<T> reg = registrations.remove(path);
+        if(reg != null) {
+            try {
+                reg.close();
+            } catch (final Exception e) {
+                // FIXME: Once we have proper subclass of ObjectRegistrationo
+                throw Throwables.propagate(e);
+            }
+        }
+    }
+
+    @Override
+    public synchronized void close() {
+        try {
+            for(final ObjectRegistration<T> reg : registrations.values()) {
+                    reg.close();
+            }
+        } catch (final Exception e) {
+            throw Throwables.propagate(e);
+        }
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/DelegatedRootRpcRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/DelegatedRootRpcRegistration.java
new file mode 100644 (file)
index 0000000..1c3e6d8
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 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.compat;
+
+import com.google.common.base.Throwables;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+final class DelegatedRootRpcRegistration<T extends RpcService> implements RpcRegistration<T> {
+
+    private final ObjectRegistration<T> delegate;
+    private final Class<T> type;
+
+    public DelegatedRootRpcRegistration(final Class<T> type,final ObjectRegistration<T> impl) {
+        this.delegate = impl;
+        this.type = type;
+    }
+
+
+    @Override
+    public void close() {
+        try {
+            // FIXME: Should use more specific registration object.
+            delegate.close();
+        } catch (final Exception e) {
+            throw Throwables.propagate(e);
+        }
+    }
+
+    @Override
+    public T getInstance() {
+        return delegate.getInstance();
+    }
+
+    @Override
+    public Class<T> getServiceType() {
+        return type;
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumRpcProviderRegistry.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumRpcProviderRegistry.java
new file mode 100644 (file)
index 0000000..555c96e
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015 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.compat;
+
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public class HeliumRpcProviderRegistry implements RpcProviderRegistry {
+
+    private final RpcConsumerRegistry consumerRegistry;
+    private final BindingDOMRpcProviderServiceAdapter providerAdapter;
+
+    public HeliumRpcProviderRegistry(final RpcConsumerRegistry consumerRegistry,
+            final BindingDOMRpcProviderServiceAdapter providerAdapter) {
+        this.consumerRegistry = consumerRegistry;
+        this.providerAdapter = providerAdapter;
+    }
+
+    @Override
+    public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type, final T impl)
+            throws IllegalStateException {
+        return new CompositeRoutedRpcRegistration<>(type,impl,providerAdapter);
+    }
+
+    @Override
+    public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type, final T impl)
+            throws IllegalStateException {
+        final ObjectRegistration<T> reg = providerAdapter.registerRpcImplementation(type, impl);
+        return new DelegatedRootRpcRegistration<>(type,reg);
+    }
+
+    @Override
+    public <T extends RpcService> T getRpcService(final Class<T> type) {
+        return consumerRegistry.getRpcService(type);
+    }
+
+    @Override
+    public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
+            final L arg0) {
+        // FIXME: Implement this only if necessary
+        return null;
+    }
+
+}
@@ -5,7 +5,7 @@
  * 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.impl;
+package org.opendaylight.controller.md.sal.binding.compat;
 
 import com.google.common.base.Function;
 import com.google.common.util.concurrent.AsyncFunction;
@@ -23,6 +23,8 @@ import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutionException;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
@@ -34,12 +36,10 @@ import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegis
 import org.opendaylight.controller.md.sal.common.api.data.DataReader;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
 import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
 import org.opendaylight.yangtools.concepts.Delegator;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
@@ -53,23 +53,23 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @Deprecated
-public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDataBroker implements DataProviderService, AutoCloseable {
+public class HydrogenDataBrokerAdapter implements DataProviderService, AutoCloseable {
 
-    private static final Logger LOG = LoggerFactory.getLogger(ForwardedBackwardsCompatibleDataBroker.class);
+    private static final Logger LOG = LoggerFactory.getLogger(HydrogenDataBrokerAdapter.class);
 
     private final ConcurrentHashMap<InstanceIdentifier<?>, CommitHandlerRegistrationImpl> commitHandlers = new ConcurrentHashMap<>();
-    private final ListeningExecutorService executorService;
+    private final ListeningExecutorService executorService = SingletonHolder.getDefaultCommitExecutor();
 
-    public ForwardedBackwardsCompatibleDataBroker(final DOMDataBroker domDataBroker,
-            final BindingToNormalizedNodeCodec mappingService, final SchemaService schemaService,final ListeningExecutorService executor) {
-        super(domDataBroker, mappingService,schemaService);
-        executorService = executor;
+    private final DataBroker delegate;
+
+    public HydrogenDataBrokerAdapter(final DataBroker dataBroker) {
+        delegate = dataBroker;
         LOG.info("ForwardedBackwardsCompatibleBroker started.");
     }
 
     @Override
     public DataModificationTransaction beginTransaction() {
-        return new ForwardedBackwardsCompatibleTransacion(getDelegate().newReadWriteTransaction(), getCodec());
+        return new ForwardedBackwardsCompatibleTransacion(delegate.newReadWriteTransaction());
     }
 
     @Override
@@ -88,11 +88,6 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
     public Registration registerCommitHandler(
             final InstanceIdentifier<? extends DataObject> path,
             final DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> commitHandler) {
-
-
-        //transformingCommitHandler = new TransformingDataChangeListener
-        //fakeCommitHandler =  registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, listener, DataChangeScope.SUBTREE);
-
         CommitHandlerRegistrationImpl reg = new CommitHandlerRegistrationImpl(path, commitHandler);
         commitHandlers.put(path, reg);
         return reg;
@@ -113,8 +108,8 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
         org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncOperListener = new BackwardsCompatibleOperationalDataChangeInvoker(listener);
         org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncCfgListener = new BackwardsCompatibleConfigurationDataChangeInvoker(listener);
 
-        ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> cfgReg = registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, asyncCfgListener, DataChangeScope.SUBTREE);
-        ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> operReg = registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, path, asyncOperListener, DataChangeScope.SUBTREE);
+        ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> cfgReg = delegate.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, asyncCfgListener, DataChangeScope.SUBTREE);
+        ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> operReg = delegate.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, path, asyncOperListener, DataChangeScope.SUBTREE);
 
         return new LegacyListenerRegistration(listener,cfgReg,operReg);
     }
@@ -159,7 +154,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
             @Override
             public ListenableFuture<RpcResult<TransactionStatus>> apply(final Boolean requestCommitSuccess) throws Exception {
                 if(requestCommitSuccess) {
-                    return AbstractDataTransaction.convertToLegacyCommitFuture(tx.getDelegate().submit());
+                    return AbstractDataTransaction.convertToLegacyCommitFuture(tx.delegate.submit());
                 }
                 return Futures.immediateFuture(RpcResultBuilder.<TransactionStatus>failed().withResult(TransactionStatus.FAILED).build());
             }
@@ -184,8 +179,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
     }
 
     @Deprecated
-    private class ForwardedBackwardsCompatibleTransacion extends
-            AbstractReadWriteTransaction implements DataModificationTransaction {
+    private class ForwardedBackwardsCompatibleTransacion implements DataModificationTransaction {
 
         private final ListenerRegistry<DataTransactionListener> listeners = ListenerRegistry.create();
         private final Map<InstanceIdentifier<? extends DataObject>, DataObject> updated = new HashMap<>();
@@ -197,15 +191,16 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
         private final Set<InstanceIdentifier<? extends DataObject>> posponedRemovedOperational = new HashSet<>();
         private final Set<InstanceIdentifier<? extends DataObject>> posponedRemovedConfiguration = new HashSet<>();
 
+        private final ReadWriteTransaction delegate;
+
 
         @Override
         public final TransactionStatus getStatus() {
             return status;
         }
 
-        protected ForwardedBackwardsCompatibleTransacion(final DOMDataReadWriteTransaction delegate,
-                final BindingToNormalizedNodeCodec codec) {
-            super(delegate, codec);
+        protected ForwardedBackwardsCompatibleTransacion(final ReadWriteTransaction delegate) {
+            this.delegate = delegate;
             LOG.debug("Tx {} allocated.",getIdentifier());
         }
 
@@ -216,9 +211,9 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
             @SuppressWarnings({ "rawtypes", "unchecked" })
             final InstanceIdentifier<DataObject> castedPath = (InstanceIdentifier) path;
             if(previouslyRemoved) {
-                put(LogicalDatastoreType.OPERATIONAL, castedPath, data,true);
+                delegate.put(LogicalDatastoreType.OPERATIONAL, castedPath, data,true);
             } else {
-                merge(LogicalDatastoreType.OPERATIONAL, castedPath, data,true);
+                delegate.merge(LogicalDatastoreType.OPERATIONAL, castedPath, data,true);
             }
         }
 
@@ -236,9 +231,9 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
             @SuppressWarnings({"rawtypes","unchecked"})
             final InstanceIdentifier<DataObject> castedPath = (InstanceIdentifier) path;
             if(previouslyRemoved) {
-                put(LogicalDatastoreType.CONFIGURATION, castedPath, data,true);
+                delegate.put(LogicalDatastoreType.CONFIGURATION, castedPath, data,true);
             } else {
-                merge(LogicalDatastoreType.CONFIGURATION, castedPath, data,true);
+                delegate.merge(LogicalDatastoreType.CONFIGURATION, castedPath, data,true);
             }
         }
 
@@ -295,7 +290,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
         @Override
         public DataObject readOperationalData(final InstanceIdentifier<? extends DataObject> path) {
             try {
-                return doRead(getDelegate(), LogicalDatastoreType.OPERATIONAL, path).get().orNull();
+                return delegate.read(LogicalDatastoreType.OPERATIONAL, path).get().orNull();
             } catch (InterruptedException | ExecutionException e) {
                 LOG.error("Read of {} failed.", path,e);
                 return null;
@@ -305,7 +300,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
         @Override
         public DataObject readConfigurationData(final InstanceIdentifier<? extends DataObject> path) {
             try {
-                return doRead(getDelegate(), LogicalDatastoreType.CONFIGURATION, path).get().orNull();
+                return delegate.read(LogicalDatastoreType.CONFIGURATION, path).get().orNull();
             } catch (InterruptedException | ExecutionException e) {
                 LOG.error("Read of {} failed.", path,e);
                 return null;
@@ -329,16 +324,16 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
         public ListenableFuture<RpcResult<TransactionStatus>> commit() {
 
             for(InstanceIdentifier<? extends DataObject> path : posponedRemovedConfiguration) {
-                doDelete(LogicalDatastoreType.CONFIGURATION, path);
+                delegate.delete(LogicalDatastoreType.CONFIGURATION, path);
             }
 
             for(InstanceIdentifier<? extends DataObject> path : posponedRemovedOperational) {
-                doDelete(LogicalDatastoreType.OPERATIONAL, path);
+                delegate.delete(LogicalDatastoreType.OPERATIONAL, path);
             }
 
             changeStatus(TransactionStatus.SUBMITED);
 
-            final ListenableFuture<RpcResult<TransactionStatus>> f = ForwardedBackwardsCompatibleDataBroker.this.commit(this);
+            final ListenableFuture<RpcResult<TransactionStatus>> f = HydrogenDataBrokerAdapter.this.commit(this);
 
             Futures.addCallback(f, new FutureCallback<RpcResult<TransactionStatus>>() {
                 @Override
@@ -361,6 +356,12 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
             return listeners.register(listener);
         }
 
+        @Override
+        public Object getIdentifier() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
     }
 
     private class CommitHandlerRegistrationImpl extends
@@ -422,7 +423,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
         @Override
         public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
 
-            DataChangeEvent legacyChange = LegacyDataChangeEvent.createOperational(change);
+            DataChangeEvent legacyChange = HydrogenDataChangeEvent.createOperational(change);
             delegate.onDataChanged(legacyChange);
 
         }
@@ -445,7 +446,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
         @Override
         public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
 
-            DataChangeEvent legacyChange = LegacyDataChangeEvent.createConfiguration(change);
+            DataChangeEvent legacyChange = HydrogenDataChangeEvent.createConfiguration(change);
 
             delegate.onDataChanged(legacyChange);
 
@@ -457,4 +458,9 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
         }
 
     }
+
+    @Override
+    public void close() throws Exception {
+        // TODO Auto-generated method stub
+    }
 }
@@ -5,7 +5,7 @@
  * 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.impl;
+package org.opendaylight.controller.md.sal.binding.compat;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -18,10 +18,10 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 @Deprecated
-public abstract class LegacyDataChangeEvent implements
+public abstract class HydrogenDataChangeEvent implements
         DataChangeEvent<InstanceIdentifier<? extends DataObject>, DataObject> {
 
-    private LegacyDataChangeEvent() {
+    private HydrogenDataChangeEvent() {
     }
 
     public static final DataChangeEvent<InstanceIdentifier<?>, DataObject> createOperational(
@@ -95,7 +95,7 @@ public abstract class LegacyDataChangeEvent implements
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
-    private final static class OperationalChangeEvent extends LegacyDataChangeEvent {
+    private final static class OperationalChangeEvent extends HydrogenDataChangeEvent {
 
         private final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> delegate;
         private Map<InstanceIdentifier<?>, DataObject> updatedCache;
@@ -150,7 +150,7 @@ public abstract class LegacyDataChangeEvent implements
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
-    private final static class ConfigurationChangeEvent extends LegacyDataChangeEvent {
+    private final static class ConfigurationChangeEvent extends HydrogenDataChangeEvent {
 
         private final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> delegate;
         private Map<InstanceIdentifier<?>, DataObject> updatedCache;
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenMountInstanceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenMountInstanceAdapter.java
new file mode 100644 (file)
index 0000000..e7aea8d
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2015 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.compat;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableClassToInstanceMap;
+import java.util.concurrent.ExecutorService;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration;
+import org.opendaylight.controller.md.sal.common.api.data.DataReader;
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.BindingAwareService;
+import org.opendaylight.controller.sal.binding.api.NotificationListener;
+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.DataChangeListener;
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+@Deprecated
+public class HydrogenMountInstanceAdapter implements MountProviderInstance {
+
+    private final ClassToInstanceMap<BindingAwareService> services;
+    private final InstanceIdentifier<?> identifier;
+
+
+    public HydrogenMountInstanceAdapter(final MountPoint key) {
+        this.identifier = key.getIdentifier();
+        final ImmutableClassToInstanceMap.Builder<BindingAwareService> builder = ImmutableClassToInstanceMap.builder();
+
+        final Optional<DataBroker> dataBroker = key.getService(DataBroker.class);
+        if(dataBroker.isPresent()) {
+            builder.put(DataBrokerService.class, new HydrogenDataBrokerAdapter(dataBroker.get()));
+        }
+        final Optional<org.opendaylight.controller.md.sal.binding.api.NotificationService> notificationService = key.getService(org.opendaylight.controller.md.sal.binding.api.NotificationService.class);
+        if(notificationService.isPresent()) {
+            builder.put(NotificationService.class, new HeliumNotificationServiceAdapter(notificationService.get()));
+        }
+        final Optional<RpcConsumerRegistry> rpcRegistry = key.getService(RpcConsumerRegistry.class);
+        if(rpcRegistry.isPresent()) {
+            builder.put(RpcConsumerRegistry.class, rpcRegistry.get());
+        }
+        services = builder.build();
+    }
+
+
+    private <T extends BindingAwareService> T service(final Class<T> service) {
+        final T potential = services.getInstance(service);
+        Preconditions.checkState(potential != null, "Service %s is not supported by mount point %s",service,this.getIdentifier());
+        return potential;
+    }
+
+    @Override
+    public <T extends RpcService> T getRpcService(final Class<T> serviceInterface) {
+        return service(RpcConsumerRegistry.class).getRpcService(serviceInterface);
+    }
+
+    @Override
+    public InstanceIdentifier<?> getIdentifier() {
+        return identifier;
+    }
+
+    @Override
+    public <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(
+            final Class<T> notificationType, final NotificationListener<T> listener) {
+        return service(NotificationService.class).registerNotificationListener(notificationType, listener);
+    }
+
+    @Override
+    public ListenerRegistration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(
+            final org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
+        return service(NotificationService.class).registerNotificationListener(listener);
+    }
+
+    @Override
+    public DataModificationTransaction beginTransaction() {
+        return service(DataBrokerService.class).beginTransaction();
+    }
+
+    @Override
+    public DataObject readConfigurationData(final InstanceIdentifier<? extends DataObject> path) {
+        return service(DataBrokerService.class).readConfigurationData(path);
+    }
+
+    @Override
+    public DataObject readOperationalData(final InstanceIdentifier<? extends DataObject> path) {
+        return service(DataBrokerService.class).readOperationalData(path);
+    }
+
+    @Override
+    public ListenerRegistration<DataChangeListener> registerDataChangeListener(
+            final InstanceIdentifier<? extends DataObject> path, final DataChangeListener listener) {
+        return service(DataBrokerService.class).registerDataChangeListener(path,listener);
+    }
+
+    @Override
+    public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> serviceInterface,
+            final T implementation) throws IllegalStateException {
+        return service(RpcProviderRegistry.class).addRoutedRpcImplementation(serviceInterface, implementation);
+    }
+
+    @Override
+    public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> serviceInterface, final T implementation)
+            throws IllegalStateException {
+        return service(RpcProviderRegistry.class).addRpcImplementation(serviceInterface, implementation);
+    }
+
+    @Override
+    public void publish(final Notification notification) {
+        service(NotificationProviderService.class).publish(notification);
+    }
+
+    @Override
+    public void publish(final Notification notification, final ExecutorService executor) {
+        service(NotificationProviderService.class).publish(notification);
+    }
+
+    @Override
+    public Registration registerCommitHandler(final InstanceIdentifier<? extends DataObject> arg0,
+            final DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> arg1) {
+        return service(DataProviderService.class).registerCommitHandler(arg0, arg1);
+    }
+
+    @Override
+    public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject>>> registerCommitHandlerListener(
+            final RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject>> arg0) {
+        return service(DataProviderService.class).registerCommitHandlerListener(arg0);
+    }
+
+    @Override
+    public Registration registerDataReader(final InstanceIdentifier<? extends DataObject> path,
+            final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> reader) {
+        return service(DataProviderService.class).registerDataReader(path, reader);
+    }
+
+    @Override
+    public ListenerRegistration<NotificationInterestListener> registerInterestListener(
+            final NotificationInterestListener interestListener) {
+        return service(NotificationProviderService.class).registerInterestListener(interestListener);
+    }
+
+    @Override
+    public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
+            final L arg0) {
+        return service(RpcProviderRegistry.class).registerRouteChangeListener(arg0);
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenMountPointServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenMountPointServiceAdapter.java
new file mode 100644 (file)
index 0000000..cecd461
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 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.compat;
+
+import com.google.common.base.Optional;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.controller.sal.binding.api.mount.MountService;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+@Deprecated
+public class HydrogenMountPointServiceAdapter implements MountService {
+
+    private final MountPointService delegate;
+
+    public HydrogenMountPointServiceAdapter(final MountPointService mountService) {
+        delegate = mountService;
+    }
+
+    private final LoadingCache<MountPoint, HydrogenMountInstanceAdapter> mountAdapters = CacheBuilder.newBuilder().weakKeys()
+            .build(new CacheLoader<MountPoint, HydrogenMountInstanceAdapter>() {
+
+                @Override
+                public HydrogenMountInstanceAdapter load(final MountPoint key) throws Exception {
+                    return new HydrogenMountInstanceAdapter(key);
+                }
+            });
+
+    @Override
+    public HydrogenMountInstanceAdapter getMountPoint(final InstanceIdentifier<?> path) {
+        final Optional<MountPoint> mount = delegate.getMountPoint(path);
+        if (mount.isPresent()) {
+            return mountAdapters.getUnchecked(mount.get());
+        }
+        return null;
+    }
+
+    MountPointService getDelegate() {
+        return delegate;
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenMountProvisionServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenMountProvisionServiceAdapter.java
new file mode 100644 (file)
index 0000000..b2ee1a5
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015 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.compat;
+
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
+import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+@Deprecated
+public class HydrogenMountProvisionServiceAdapter extends HydrogenMountPointServiceAdapter implements MountProviderService {
+
+    public HydrogenMountProvisionServiceAdapter(final MountPointService mountService) {
+        super(mountService);
+    }
+
+    @Override
+    public MountProviderInstance createMountPoint(final InstanceIdentifier<?> path) {
+        throw new UnsupportedOperationException("Not implemented");
+    }
+
+    @Override
+    public MountProviderInstance createOrGetMountPoint(final InstanceIdentifier<?> path) {
+        return getMountPoint(path);
+    }
+
+    @Override
+    public ListenerRegistration<MountProvisionListener> registerProvisionListener(final MountProvisionListener listener) {
+        return new ListenerRegistration<MountProvisionListener>() {
+
+            @Override
+            public MountProvisionListener getInstance() {
+                return listener;
+            }
+
+            @Override
+            public void close() {
+            }
+        };
+    }
+
+}
index 273155b..b37bb04 100644 (file)
@@ -9,23 +9,18 @@ package org.opendaylight.controller.md.sal.binding.impl;
 
 import com.google.common.base.Objects;
 import com.google.common.base.Optional;
-
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
-
 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
-import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;
-import org.opendaylight.controller.sal.binding.impl.forward.DomForwardedBroker;
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
 import org.opendaylight.yangtools.concepts.Delegator;
@@ -35,28 +30,26 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public abstract class AbstractForwardedDataBroker implements Delegator<DOMDataBroker>, DomForwardedBroker,
-        SchemaContextListener, AutoCloseable {
+public abstract class AbstractForwardedDataBroker implements Delegator<DOMDataBroker>, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractForwardedDataBroker.class);
     // The Broker to whom we do all forwarding
     private final DOMDataBroker domDataBroker;
 
     private final BindingToNormalizedNodeCodec codec;
-    private BindingIndependentConnector connector;
-    private ProviderSession context;
-    private final ListenerRegistration<SchemaContextListener> schemaListenerRegistration;
 
     protected AbstractForwardedDataBroker(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec,
             final SchemaService schemaService) {
         this.domDataBroker = domDataBroker;
         this.codec = codec;
-        this.schemaListenerRegistration = schemaService.registerSchemaContextListener(this);
+    }
+
+    protected AbstractForwardedDataBroker(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec) {
+        this.domDataBroker = domDataBroker;
+        this.codec = codec;
     }
 
     protected BindingToNormalizedNodeCodec getCodec() {
@@ -68,33 +61,28 @@ public abstract class AbstractForwardedDataBroker implements Delegator<DOMDataBr
         return domDataBroker;
     }
 
-    @Override
-    public void onGlobalContextUpdated(final SchemaContext ctx) {
-        // NOOP
-    }
-
     public ListenerRegistration<DataChangeListener> registerDataChangeListener(final LogicalDatastoreType store,
             final InstanceIdentifier<?> path, final DataChangeListener listener, final DataChangeScope triggeringScope) {
-        DOMDataChangeListener domDataChangeListener = new TranslatingDataChangeInvoker(store, path, listener,
+        final DOMDataChangeListener domDataChangeListener = new TranslatingDataChangeInvoker(store, path, listener,
                 triggeringScope);
-        YangInstanceIdentifier domPath = codec.toNormalized(path);
-        ListenerRegistration<DOMDataChangeListener> domRegistration = domDataBroker.registerDataChangeListener(store,
+        final YangInstanceIdentifier domPath = codec.toNormalized(path);
+        final ListenerRegistration<DOMDataChangeListener> domRegistration = domDataBroker.registerDataChangeListener(store,
                 domPath, domDataChangeListener, triggeringScope);
         return new ListenerRegistrationImpl(listener, domRegistration);
     }
 
     protected Map<InstanceIdentifier<?>, DataObject> toBinding(final InstanceIdentifier<?> path,
             final Map<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> normalized) {
-        Map<InstanceIdentifier<?>, DataObject> newMap = new HashMap<>();
+        final Map<InstanceIdentifier<?>, DataObject> newMap = new HashMap<>();
 
-        for (Map.Entry<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> entry : normalized.entrySet()) {
+        for (final Map.Entry<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> entry : normalized.entrySet()) {
             try {
-                Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> potential = getCodec().toBinding(entry);
+                final Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> potential = getCodec().toBinding(entry);
                 if (potential.isPresent()) {
-                    Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding = potential.get();
+                    final Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding = potential.get();
                     newMap.put(binding.getKey(), binding.getValue());
                 }
-            } catch (DeserializationException e) {
+            } catch (final DeserializationException e) {
                 LOG.warn("Failed to transform {}, omitting it", entry, e);
             }
         }
@@ -103,17 +91,17 @@ public abstract class AbstractForwardedDataBroker implements Delegator<DOMDataBr
 
     protected Set<InstanceIdentifier<?>> toBinding(final InstanceIdentifier<?> path,
             final Set<YangInstanceIdentifier> normalized) {
-        Set<InstanceIdentifier<?>> hashSet = new HashSet<>();
-        for (YangInstanceIdentifier normalizedPath : normalized) {
+        final Set<InstanceIdentifier<?>> hashSet = new HashSet<>();
+        for (final YangInstanceIdentifier normalizedPath : normalized) {
             try {
-                Optional<InstanceIdentifier<? extends DataObject>> potential = getCodec().toBinding(normalizedPath);
+                final Optional<InstanceIdentifier<? extends DataObject>> potential = getCodec().toBinding(normalizedPath);
                 if (potential.isPresent()) {
-                    InstanceIdentifier<? extends DataObject> binding = potential.get();
+                    final InstanceIdentifier<? extends DataObject> binding = potential.get();
                     hashSet.add(binding);
                 } else if (normalizedPath.getLastPathArgument() instanceof YangInstanceIdentifier.AugmentationIdentifier) {
                     hashSet.add(path);
                 }
-            } catch (DeserializationException e) {
+            } catch (final DeserializationException e) {
                 LOG.warn("Failed to transform {}, omitting it", normalizedPath, e);
             }
         }
@@ -255,33 +243,7 @@ public abstract class AbstractForwardedDataBroker implements Delegator<DOMDataBr
     }
 
     @Override
-    public BindingIndependentConnector getConnector() {
-        return this.connector;
-    }
-
-    @Override
-    public ProviderSession getDomProviderContext() {
-        return this.context;
-    }
-
-    @Override
-    public void setConnector(final BindingIndependentConnector connector) {
-        this.connector = connector;
-    }
-
-    @Override
-    public void setDomProviderContext(final ProviderSession domProviderContext) {
-        this.context = domProviderContext;
-    }
-
-    @Override
-    public void startForwarding() {
-        // NOOP
-    }
-
-    @Override
-    public void close() throws Exception {
-        this.schemaListenerRegistration.close();
+    public void close() {
     }
 
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterBuilder.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterBuilder.java
new file mode 100644 (file)
index 0000000..d460c48
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015 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.impl;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ClassToInstanceMap;
+import org.opendaylight.controller.md.sal.binding.api.BindingService;
+import org.opendaylight.controller.md.sal.binding.spi.AdapterBuilder;
+import org.opendaylight.controller.md.sal.dom.api.DOMService;
+
+abstract class BindingDOMAdapterBuilder<T extends BindingService> extends AdapterBuilder<T, DOMService> {
+
+    interface Factory<T extends BindingService> {
+
+        BindingDOMAdapterBuilder<T> newBuilder();
+
+    }
+
+    private BindingToNormalizedNodeCodec codec;
+
+    public void setCodec(final BindingToNormalizedNodeCodec codec) {
+        this.codec = codec;
+    }
+
+    @Override
+    protected final T createInstance(final ClassToInstanceMap<DOMService> delegates) {
+        Preconditions.checkState(codec != null);
+        return createInstance(codec,delegates);
+    }
+
+    protected abstract T createInstance(BindingToNormalizedNodeCodec codec2, ClassToInstanceMap<DOMService> delegates);
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterLoader.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterLoader.java
new file mode 100644 (file)
index 0000000..79c9749
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 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.impl;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import org.opendaylight.controller.md.sal.binding.api.BindingService;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
+import org.opendaylight.controller.md.sal.binding.spi.AdapterBuilder;
+import org.opendaylight.controller.md.sal.binding.spi.AdapterLoader;
+import org.opendaylight.controller.md.sal.dom.api.DOMService;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+
+public abstract class BindingDOMAdapterLoader extends AdapterLoader<BindingService, DOMService> {
+
+
+    private static final Map<Class<?>,BindingDOMAdapterBuilder.Factory<?>> FACTORIES = ImmutableMap.<Class<?>,BindingDOMAdapterBuilder.Factory<?>>builder()
+            .put(NotificationService.class,ForwardedNotificationService.BUILDER_FACTORY)
+            .put(NotificationPublishService.class,ForwardedNotificationPublishService.BUILDER_FACTORY)
+            .put(DataBroker.class,ForwardedBindingDataBroker.BUILDER_FACTORY)
+            .put(RpcConsumerRegistry.class,BindingDOMRpcServiceAdapter.BUILDER_FACTORY)
+            .build();
+
+    private final BindingToNormalizedNodeCodec codec;
+
+    public BindingDOMAdapterLoader(final BindingToNormalizedNodeCodec codec) {
+        super();
+        this.codec = codec;
+    }
+
+    @Override
+    protected final AdapterBuilder<? extends BindingService, DOMService> createBuilder(final Class<? extends BindingService> key)
+            throws IllegalArgumentException {
+        final Factory<?> factory = FACTORIES.get(key);
+        Preconditions.checkArgument(factory != null, "Unsupported service type %s", key);
+        final BindingDOMAdapterBuilder<?> builder = factory.newBuilder();
+        builder.setCodec(codec);
+        return builder;
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointListenerAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointListenerAdapter.java
new file mode 100644 (file)
index 0000000..5698156
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015 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.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.MountPointService.MountPointListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
+
+final class BindingDOMMountPointListenerAdapter<T extends MountPointListener> implements ListenerRegistration<T>, MountProvisionListener {
+
+    private final T listener;
+    private final ListenerRegistration<MountProvisionListener> registration;
+    private final BindingToNormalizedNodeCodec codec;
+
+    public BindingDOMMountPointListenerAdapter(final T listener, final BindingToNormalizedNodeCodec codec, final DOMMountPointService mountService) {
+        this.listener = listener;
+        this.codec = codec;
+        this.registration = mountService.registerProvisionListener(this);
+    }
+
+    @Override
+    public T getInstance() {
+        return listener;
+    }
+
+    @Override
+    public void close() {
+        registration.close();
+    }
+
+    @Override
+    public void onMountPointCreated(final YangInstanceIdentifier path) {
+        try {
+            final InstanceIdentifier<? extends DataObject> bindingPath = codec.toBinding(path).get();
+            listener.onMountPointCreated(bindingPath);
+        } catch (final DeserializationException e) {
+            BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}. Ommiting event.",path,e);
+        }
+
+    }
+
+    @Override
+    public void onMountPointRemoved(final YangInstanceIdentifier path) {
+        try {
+            final InstanceIdentifier<? extends DataObject> bindingPath = codec.toBinding(path).get();
+            listener.onMountPointRemoved(bindingPath);
+        } catch (final DeserializationException e) {
+            BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}. Ommiting event.",path,e);
+        }
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java
new file mode 100644 (file)
index 0000000..3a63fba
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015 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.impl;
+
+import com.google.common.base.Optional;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class BindingDOMMountPointServiceAdapter implements MountPointService {
+
+    public static final Logger LOG = LoggerFactory.getLogger(BindingDOMMountPointServiceAdapter.class);
+
+    private final BindingToNormalizedNodeCodec codec;
+    private final DOMMountPointService mountService;
+    private final LoadingCache<DOMMountPoint, BindingMountPointAdapter> bindingMountpoints = CacheBuilder.newBuilder()
+            .build(new CacheLoader<DOMMountPoint, BindingMountPointAdapter>() {
+
+                @Override
+                public BindingMountPointAdapter load(DOMMountPoint key) throws Exception {
+                    return new BindingMountPointAdapter(codec,key);
+                }
+            });
+
+    public BindingDOMMountPointServiceAdapter(DOMMountPointService mountService,BindingToNormalizedNodeCodec codec) {
+        this.codec = codec;
+        this.mountService = mountService;
+    }
+
+    @Override
+    public Optional<MountPoint> getMountPoint(InstanceIdentifier<?> mountPoint) {
+
+        YangInstanceIdentifier domPath = codec.toNormalized(mountPoint);
+        Optional<DOMMountPoint> domMount = mountService.getMountPoint(domPath);
+        if(domMount.isPresent()) {
+            return Optional.<MountPoint>fromNullable(bindingMountpoints.getUnchecked(domMount.get()));
+        }
+        return Optional.absent();
+    }
+
+    @Override
+    public <T extends MountPointListener> ListenerRegistration<T> registerListener(InstanceIdentifier<?> path,
+            T listener) {
+        return new BindingDOMMountPointListenerAdapter<T>(listener,codec,mountService);
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcAdapterRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcAdapterRegistration.java
new file mode 100644 (file)
index 0000000..c971fc6
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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.impl;
+
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+class BindingDOMRpcAdapterRegistration<T extends RpcService> extends AbstractObjectRegistration<T>{
+
+    private final DOMRpcImplementationRegistration<?> reg;
+
+    public BindingDOMRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration<?> reg) {
+        super(instance);
+        this.reg = reg;
+    }
+
+    @Override
+    protected void removeRegistration() {
+        reg.close();
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java
new file mode 100644 (file)
index 0000000..d76d4f9
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2015 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.impl;
+
+import com.google.common.base.Function;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.JdkFutureAdapters;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Collection;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+import org.opendaylight.yangtools.yang.binding.util.RpcServiceInvoker;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation {
+
+    private static final Function<? super Exception, DOMRpcException> EXCEPTION_MAPPER = new Function<Exception, DOMRpcException>() {
+
+        @Override
+        public DOMRpcException apply(final Exception input) {
+            // FIXME: Return correct exception
+            return null;
+        }
+
+    };
+    private final BindingNormalizedNodeCodecRegistry codec;
+    private final RpcServiceInvoker invoker;
+    private final RpcService delegate;
+    private final QNameModule module;
+
+    public <T extends RpcService> BindingDOMRpcImplementationAdapter(final BindingNormalizedNodeCodecRegistry codec, final Class<T> type ,final T delegate) {
+        this.codec = codec;
+        this.delegate = delegate;
+        this.invoker = RpcServiceInvoker.from(type);
+        this.module = BindingReflections.getQNameModule(type);
+    }
+
+    public QNameModule getQNameModule() {
+        return module;
+    }
+
+    @Override
+    public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
+        final SchemaPath schemaPath = rpc.getType();
+        final DataObject bindingInput = deserilialize(rpc.getType(),input);
+        final ListenableFuture<RpcResult<?>> bindingResult = invoke(schemaPath,bindingInput);
+        return transformResult(schemaPath,bindingResult);
+    }
+
+    private DataObject deserilialize(final SchemaPath rpcPath, final NormalizedNode<?, ?> input) {
+        if(input instanceof LazySerializedContainerNode) {
+            return ((LazySerializedContainerNode) input).bindingData();
+        }
+        final SchemaPath inputSchemaPath = rpcPath.createChild(QName.create(module,"input"));
+        return codec.fromNormalizedNodeRpcData(inputSchemaPath, (ContainerNode) input);
+    }
+
+
+    private ListenableFuture<RpcResult<?>> invoke(final SchemaPath schemaPath, final DataObject input) {
+        return JdkFutureAdapters.listenInPoolThread(invoker.invokeRpc(delegate, schemaPath.getLastComponent(), input));
+    }
+
+    private CheckedFuture<DOMRpcResult, DOMRpcException> transformResult(final SchemaPath schemaPath,
+            final ListenableFuture<RpcResult<?>> bindingResult) {
+        final ListenableFuture<DOMRpcResult> transformed = Futures.transform(bindingResult, new Function<RpcResult<?>,DOMRpcResult>() {
+
+            @Override
+            public DOMRpcResult apply(final RpcResult<?> input) {
+                return new DOMRpcResult() {
+
+                    @Override
+                    public NormalizedNode<?, ?> getResult() {
+
+                        if(input instanceof DataContainer) {
+                            return codec.toNormalizedNodeRpcData((DataContainer) input);
+                        }
+                        return null;
+                    }
+
+                    @Override
+                    public Collection<RpcError> getErrors() {
+                        return input.getErrors();
+                    }
+                };
+            }
+
+        });
+        return Futures.makeChecked(transformed, EXCEPTION_MAPPER);
+    }
+
+
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcProviderServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcProviderServiceAdapter.java
new file mode 100644 (file)
index 0000000..46bd2f8
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2015 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.impl;
+
+import com.google.common.collect.ImmutableSet;
+import java.util.HashSet;
+import java.util.Set;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+public class BindingDOMRpcProviderServiceAdapter {
+
+    private static final Set<YangInstanceIdentifier> GLOBAL = ImmutableSet.of(YangInstanceIdentifier.builder().build());
+    private final BindingToNormalizedNodeCodec codec;
+    private final DOMRpcProviderService domRpcRegistry;
+
+    public BindingDOMRpcProviderServiceAdapter(final DOMRpcProviderService domRpcRegistry, final BindingToNormalizedNodeCodec codec) {
+        this.codec = codec;
+        this.domRpcRegistry = domRpcRegistry;
+    }
+
+    public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(final Class<S> type,
+            final T implementation) {
+        return register(type,implementation,createDomRpcIdentifiers(type,GLOBAL));
+    }
+
+    public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(final Class<S> type,
+            final T implementation, final Set<InstanceIdentifier<?>> paths) {
+        return register(type,implementation,createDomRpcIdentifiers(type,toYangInstanceIdentifiers(paths)));
+    }
+
+    private <S extends RpcService, T extends S> ObjectRegistration<T> register(final Class<S> type, final T implementation, final Set<DOMRpcIdentifier> domRpcs) {
+        final BindingRpcImplementationAdapter adapter = new BindingRpcImplementationAdapter(codec.getCodecFactory(), type, implementation);
+
+
+        final DOMRpcImplementationRegistration<?> domReg = domRpcRegistry.registerRpcImplementation(adapter, domRpcs);
+        return new BindingRpcAdapterRegistration<>(implementation, domReg);
+    }
+
+    private Set<DOMRpcIdentifier> createDomRpcIdentifiers(final Class<? extends RpcService> type, final Set<YangInstanceIdentifier> paths) {
+        final Set<SchemaPath> rpcs = getRpcSchemaPaths(type);
+
+        final Set<DOMRpcIdentifier> ret = new HashSet<>();
+        for(final YangInstanceIdentifier path : paths) {
+            for(final SchemaPath rpc : rpcs) {
+                ret.add(DOMRpcIdentifier.create(rpc, path));
+            }
+        }
+        return ret;
+    }
+
+    private Set<YangInstanceIdentifier> toYangInstanceIdentifiers(final Set<InstanceIdentifier<?>> identifiers) {
+        final Set<YangInstanceIdentifier> ret = new HashSet<>();
+        for(final InstanceIdentifier<?> binding: identifiers) {
+            ret.add(codec.toNormalized(binding));
+        }
+        return ret;
+    }
+
+    private Set<SchemaPath> getRpcSchemaPaths(final Class<? extends RpcService> type) {
+        return codec.getRpcMethodToSchemaPath(type).values();
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcServiceAdapter.java
new file mode 100644 (file)
index 0000000..9694bc9
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2015 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.impl;
+
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.lang.reflect.Method;
+import java.util.Set;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
+import org.opendaylight.controller.md.sal.binding.impl.RpcServiceAdapter.InvocationDelegate;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.controller.md.sal.dom.api.DOMService;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+public class BindingDOMRpcServiceAdapter implements RpcConsumerRegistry, InvocationDelegate {
+
+    protected static final Factory<RpcConsumerRegistry> BUILDER_FACTORY = new Factory<RpcConsumerRegistry>() {
+
+        @Override
+        public BindingDOMAdapterBuilder<RpcConsumerRegistry> newBuilder() {
+            return new Builder();
+        }
+
+    };
+
+    private final LoadingCache<Class<? extends RpcService>, RpcServiceAdapter> proxies = CacheBuilder.newBuilder()
+            .weakKeys()
+            .build(new CacheLoader<Class<? extends RpcService>, RpcServiceAdapter>() {
+
+                @Override
+                public RpcServiceAdapter load(final Class<? extends RpcService> key) throws Exception {
+                    return createProxy(key);
+                }
+
+            });
+
+    private final DOMRpcService domService;
+    private final BindingToNormalizedNodeCodec codec;
+
+    public BindingDOMRpcServiceAdapter(final DOMRpcService domService, final BindingToNormalizedNodeCodec codec) {
+        super();
+        this.domService = domService;
+        this.codec = codec;
+    }
+
+    @Override
+    public <T extends RpcService> T getRpcService(final Class<T> rpcService) {
+        Preconditions.checkArgument(rpcService != null, "Rpc Service needs to be specied.");
+        @SuppressWarnings("unchecked")
+        final
+        T proxy = (T) proxies.getUnchecked(rpcService).getProxy();
+        return proxy;
+    }
+
+    @Override
+    public ListenableFuture<RpcResult<?>> invoke(final SchemaPath rpc, final DataObject input) {
+        final CheckedFuture<DOMRpcResult, DOMRpcException> domFuture = domService.invokeRpc(rpc, serialize(rpc,input));
+        return transformFuture(rpc,domFuture,codec.getCodecFactory());
+    }
+
+    private RpcServiceAdapter createProxy(final Class<? extends RpcService> key) {
+        Preconditions.checkArgument(BindingReflections.isBindingClass(key));
+        Preconditions.checkArgument(key.isInterface(), "Supplied RPC service type must be interface.");
+        final ImmutableMap<Method, SchemaPath> rpcNames = codec.getRpcMethodToSchemaPath(key);
+        return new RpcServiceAdapter(key, rpcNames, this);
+    }
+
+    private NormalizedNode<?, ?> serialize(final SchemaPath rpc,final DataObject input) {
+        if(input == null) {
+            return null;
+        }
+        final QName rpcInputIdentifier = QName.create(rpc.getLastComponent(),"input");
+        return new LazySerializedContainerNode(rpcInputIdentifier, input, codec.getCodecFactory());
+    }
+
+    private static ListenableFuture<RpcResult<?>> transformFuture(final SchemaPath rpc,final ListenableFuture<DOMRpcResult> domFuture, final BindingNormalizedNodeCodecRegistry codec) {
+        return Futures.transform(domFuture, new Function<DOMRpcResult, RpcResult<?>>() {
+            @Override
+            public RpcResult<?> apply(final DOMRpcResult input) {
+                if(input instanceof LazySerializedDOMRpcResult) {
+                    return ((LazySerializedDOMRpcResult) input).bidningRpcResult();
+                }
+                final NormalizedNode<?, ?> domData = input.getResult();
+                final DataObject bindingResult;
+                if(domData != null) {
+                    final SchemaPath rpcOutput = rpc.createChild(QName.create(rpc.getLastComponent(),"output"));
+                    bindingResult = codec.fromNormalizedNodeRpcData(rpcOutput, (ContainerNode) domData);
+                } else {
+                    bindingResult = null;
+                }
+                return RpcResult.class.cast(RpcResultBuilder.success(bindingResult).build());
+            }
+        });
+    }
+
+    private static final class Builder extends BindingDOMAdapterBuilder<RpcConsumerRegistry> {
+
+        @Override
+        protected RpcConsumerRegistry createInstance(final BindingToNormalizedNodeCodec codec,
+                final ClassToInstanceMap<DOMService> delegates) {
+            final DOMRpcService domRpc  = delegates.getInstance(DOMRpcService.class);
+            return new BindingDOMRpcServiceAdapter(domRpc  , codec);
+        }
+
+        @Override
+        public Set<? extends Class<? extends DOMService>> getRequiredDelegates() {
+            return ImmutableSet.of(DOMRpcService.class);
+        }
+
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingMountPointAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingMountPointAdapter.java
new file mode 100644 (file)
index 0000000..372771f
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 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.impl;
+
+import com.google.common.base.Optional;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.LoadingCache;
+import org.opendaylight.controller.md.sal.binding.api.BindingService;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
+import org.opendaylight.controller.md.sal.dom.api.DOMService;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class BindingMountPointAdapter implements MountPoint {
+
+    private final InstanceIdentifier<?> identifier;
+    private LoadingCache<Class<? extends BindingService>, Optional<BindingService>> services;
+
+    public BindingMountPointAdapter(final BindingToNormalizedNodeCodec codec, final DOMMountPoint domMountPoint) {
+        identifier = codec.getCodecRegistry().fromYangInstanceIdentifier(domMountPoint.getIdentifier());
+        services = CacheBuilder.newBuilder().build(new BindingDOMAdapterLoader(codec) {
+
+            @Override
+            protected DOMService getDelegate(Class<? extends DOMService> reqDeleg) {
+                return domMountPoint.getService(reqDeleg).orNull();
+            }
+        });
+    }
+
+    @Override
+    public InstanceIdentifier<?> getIdentifier() {
+        return identifier;
+    }
+
+    @Override
+    public <T extends BindingService> Optional<T> getService(Class<T> service) {
+        Optional<BindingService> potential = services.getUnchecked(service);
+        if(potential.isPresent()) {
+            return Optional.of(service.cast(potential.get()));
+        }
+        return Optional.absent();
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcAdapterRegistration.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcAdapterRegistration.java
new file mode 100644 (file)
index 0000000..5fade2c
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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.impl;
+
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+class BindingRpcAdapterRegistration<T extends RpcService> extends AbstractObjectRegistration<T>{
+
+    private final DOMRpcImplementationRegistration<?> reg;
+
+    public BindingRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration<?> reg) {
+        super(instance);
+        this.reg = reg;
+    }
+
+    @Override
+    protected void removeRegistration() {
+        reg.close();
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcImplementationAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcImplementationAdapter.java
new file mode 100644 (file)
index 0000000..9f0de74
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2015 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.impl;
+
+import com.google.common.base.Function;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.JdkFutureAdapters;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+import org.opendaylight.yangtools.yang.binding.util.RpcServiceInvoker;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+public class BindingRpcImplementationAdapter implements DOMRpcImplementation {
+
+    private static final Function<? super Exception, DOMRpcException> EXCEPTION_MAPPER = new Function<Exception, DOMRpcException>() {
+
+        @Override
+        public DOMRpcException apply(Exception input) {
+            // FIXME: Return correct exception
+            return null;
+        }
+
+    };
+    private final BindingNormalizedNodeCodecRegistry codec;
+    private final RpcServiceInvoker invoker;
+    private final RpcService delegate;
+    private final QNameModule module;
+
+    private Function<RpcResult<?>,DOMRpcResult> lazySerializedMapper = new Function<RpcResult<?>,DOMRpcResult>() {
+
+        @Override
+        public DOMRpcResult apply(final RpcResult<?> input) {
+            return LazySerializedDOMRpcResult.create(input, codec);
+        }
+    };
+
+    public <T extends RpcService> BindingRpcImplementationAdapter(BindingNormalizedNodeCodecRegistry codec, Class<T> type ,T delegate) {
+        this.codec = codec;
+        this.delegate = delegate;
+        this.invoker = RpcServiceInvoker.from(type);
+        this.module = BindingReflections.getQNameModule(type);
+    }
+
+    public QNameModule getQNameModule() {
+        return module;
+    }
+
+    @Override
+    public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(DOMRpcIdentifier rpc, NormalizedNode<?, ?> input) {
+        SchemaPath schemaPath = rpc.getType();
+        DataObject bindingInput = deserilialize(rpc.getType(),input);
+        ListenableFuture<RpcResult<?>> bindingResult = invoke(schemaPath,bindingInput);
+        return transformResult(schemaPath,bindingResult);
+    }
+
+    private DataObject deserilialize(SchemaPath rpcPath, NormalizedNode<?, ?> input) {
+        if(input instanceof LazySerializedContainerNode) {
+            return ((LazySerializedContainerNode) input).bindingData();
+        }
+        SchemaPath inputSchemaPath = rpcPath.createChild(QName.create(module,"input"));
+        return codec.fromNormalizedNodeRpcData(inputSchemaPath, (ContainerNode) input);
+    }
+
+
+    private ListenableFuture<RpcResult<?>> invoke(SchemaPath schemaPath, DataObject input) {
+        return JdkFutureAdapters.listenInPoolThread(invoker.invokeRpc(delegate, schemaPath.getLastComponent(), input));
+    }
+
+    private CheckedFuture<DOMRpcResult, DOMRpcException> transformResult(SchemaPath schemaPath,
+            ListenableFuture<RpcResult<?>> bindingResult) {
+        ListenableFuture<DOMRpcResult> transformed = Futures.transform(bindingResult, lazySerializedMapper);
+        return Futures.makeChecked(transformed, EXCEPTION_MAPPER);
+    }
+
+}
index a973e67..d5b7d05 100644 (file)
@@ -9,6 +9,8 @@ package org.opendaylight.controller.md.sal.binding.impl;
 
 import com.google.common.base.Function;
 import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableBiMap;
+import java.lang.reflect.Method;
 import java.util.Iterator;
 import java.util.Map.Entry;
 import javax.annotation.Nonnull;
@@ -18,15 +20,22 @@ import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer
 import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
 import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
 import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
+import org.opendaylight.yangtools.yang.binding.BindingMapping;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
 import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 public class BindingToNormalizedNodeCodec implements SchemaContextListener,AutoCloseable {
 
@@ -34,6 +43,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener,AutoC
     private final BindingNormalizedNodeCodecRegistry codecRegistry;
     private DataNormalizer legacyToNormalized;
     private final GeneratedClassLoadingStrategy classLoadingStrategy;
+    private BindingRuntimeContext runtimeContext;
 
     public BindingToNormalizedNodeCodec(final GeneratedClassLoadingStrategy classLoadingStrategy, final BindingIndependentMappingService mappingService, final BindingNormalizedNodeCodecRegistry codecRegistry) {
         super();
@@ -72,7 +82,7 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener,AutoC
                     throws DeserializationException {
         try {
             return Optional.<InstanceIdentifier<? extends DataObject>>fromNullable(codecRegistry.fromYangInstanceIdentifier(normalized));
-        } catch (IllegalArgumentException e) {
+        } catch (final IllegalArgumentException e) {
             return Optional.absent();
         }
     }
@@ -99,17 +109,18 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener,AutoC
              *
              */
             @SuppressWarnings({ "unchecked", "rawtypes" })
-            final Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding = (Entry) codecRegistry.fromNormalizedNode(normalized.getKey(), normalized.getValue());
+            final Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding = Entry.class.cast(codecRegistry.fromNormalizedNode(normalized.getKey(), normalized.getValue()));
             return Optional.fromNullable(binding);
-        } catch (IllegalArgumentException e) {
+        } catch (final IllegalArgumentException e) {
             return Optional.absent();
         }
     }
 
     @Override
     public void onGlobalContextUpdated(final SchemaContext arg0) {
-        legacyToNormalized = new DataNormalizer(arg0);
-        codecRegistry.onBindingRuntimeContextUpdated(BindingRuntimeContext.create(classLoadingStrategy, arg0));
+        legacyToNormalized = new DataNormalizer (arg0);
+        runtimeContext = BindingRuntimeContext.create(classLoadingStrategy, arg0);
+        codecRegistry.onBindingRuntimeContextUpdated(runtimeContext);
     }
 
     public <T extends DataObject> Function<Optional<NormalizedNode<?, ?>>, Optional<T>>  deserializeFunction(final InstanceIdentifier<T> path) {
@@ -123,13 +134,13 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener,AutoC
      * @return Node with defaults set on.
      */
     public NormalizedNode<?, ?> getDefaultNodeFor(final YangInstanceIdentifier path) {
-        Iterator<PathArgument> iterator = path.getPathArguments().iterator();
+        final Iterator<PathArgument> iterator = path.getPathArguments().iterator();
         DataNormalizationOperation<?> currentOp = legacyToNormalized.getRootOperation();
         while (iterator.hasNext()) {
-            PathArgument currentArg = iterator.next();
+            final PathArgument currentArg = iterator.next();
             try {
                 currentOp = currentOp.getChild(currentArg);
-            } catch (DataNormalizationException e) {
+            } catch (final DataNormalizationException e) {
                 throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);
             }
         }
@@ -148,4 +159,33 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener,AutoC
     public void close() {
         // NOOP Intentionally
     }
+
+    public BindingNormalizedNodeCodecRegistry getCodecFactory() {
+        return codecRegistry;
+    }
+
+    // FIXME: This should be probably part of Binding Runtime context
+    public ImmutableBiMap<Method, SchemaPath> getRpcMethodToSchemaPath(final Class<? extends RpcService> key) {
+        final QNameModule moduleName = BindingReflections.getQNameModule(key);
+        final Module module = runtimeContext.getSchemaContext().findModuleByNamespaceAndRevision(moduleName.getNamespace(), moduleName.getRevision());
+        final ImmutableBiMap.Builder<Method, SchemaPath> ret = ImmutableBiMap.<Method, SchemaPath>builder();
+        try {
+            for (final RpcDefinition rpcDef : module.getRpcs()) {
+                final Method method = findRpcMethod(key, rpcDef);
+                ret.put(method, rpcDef.getPath());
+            }
+        } catch (final NoSuchMethodException e) {
+            throw new IllegalStateException("Rpc defined in model does not have representation in generated class.", e);
+        }
+        return ret.build();
+    }
+
+    private Method findRpcMethod(final Class<? extends RpcService> key, final RpcDefinition rpcDef) throws NoSuchMethodException {
+        final String methodName = BindingMapping.getMethodName(rpcDef.getQName());
+        if(rpcDef.getInput() != null) {
+            final Class<?> inputClz = runtimeContext.getClassForSchema(rpcDef.getInput());
+            return key.getMethod(methodName, inputClz);
+        }
+        return key.getMethod(methodName);
+    }
 }
index ef66d80..bba1747 100644 (file)
@@ -8,13 +8,18 @@
 package org.opendaylight.controller.md.sal.binding.impl;
 
 
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableSet;
+import java.util.Set;
 import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMService;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 
 /**
@@ -29,6 +34,21 @@ import org.opendaylight.controller.sal.core.api.model.SchemaService;
  */
 public class ForwardedBindingDataBroker extends AbstractForwardedDataBroker implements DataBroker {
 
+
+    static final Factory<DataBroker> BUILDER_FACTORY = new BindingDOMAdapterBuilder.Factory<DataBroker>() {
+
+        @Override
+        public BindingDOMAdapterBuilder<DataBroker> newBuilder() {
+            return new Builder();
+        }
+
+    };
+
+    public ForwardedBindingDataBroker(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec) {
+        super(domDataBroker, codec);
+    }
+
+    @Deprecated
     public ForwardedBindingDataBroker(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec, final SchemaService schemaService) {
         super(domDataBroker, codec,schemaService);
     }
@@ -53,4 +73,22 @@ public class ForwardedBindingDataBroker extends AbstractForwardedDataBroker impl
     public BindingTransactionChain createTransactionChain(final TransactionChainListener listener) {
         return new BindingTranslatedTransactionChain(getDelegate(), getCodec(), listener);
     }
+
+    private static class Builder extends BindingDOMAdapterBuilder<DataBroker> {
+
+        @Override
+        public Set<? extends Class<? extends DOMService>> getRequiredDelegates() {
+            return ImmutableSet.of(DOMDataBroker.class);
+        }
+
+        @Override
+        protected DataBroker createInstance(BindingToNormalizedNodeCodec codec,
+                ClassToInstanceMap<DOMService> delegates) {
+            DOMDataBroker domDataBroker = delegates.getInstance(DOMDataBroker.class);
+            return new ForwardedBindingDataBroker(domDataBroker, codec);
+        }
+
+
+
+    }
 }
index 14d6713..13b53ad 100644 (file)
@@ -7,18 +7,33 @@
  */
 package org.opendaylight.controller.md.sal.binding.impl;
 
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService;
+import org.opendaylight.controller.md.sal.dom.api.DOMService;
 import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.yangtools.yang.binding.Notification;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 public class ForwardedNotificationPublishService implements NotificationPublishService, AutoCloseable {
+
+    static final Factory<NotificationPublishService> BUILDER_FACTORY = new BindingDOMAdapterBuilder.Factory<NotificationPublishService>() {
+
+        @Override
+        public BindingDOMAdapterBuilder<NotificationPublishService> newBuilder() {
+            return new Builder();
+        }
+
+    };
+
     private final BindingNormalizedNodeSerializer codecRegistry;
     private final DOMNotificationPublishService domPublishService;
 
@@ -77,4 +92,21 @@ public class ForwardedNotificationPublishService implements NotificationPublishS
             return this.body;
         }
     }
+
+    protected static class Builder extends BindingDOMAdapterBuilder<NotificationPublishService> {
+
+        @Override
+        public Set<Class<? extends DOMService>> getRequiredDelegates() {
+            return ImmutableSet.<Class<? extends DOMService>>of(DOMNotificationPublishService.class);
+        }
+
+        @Override
+        protected NotificationPublishService createInstance(BindingToNormalizedNodeCodec codec,
+                ClassToInstanceMap<DOMService> delegates) {
+            BindingNormalizedNodeSerializer codecReg = codec.getCodecRegistry();
+            DOMNotificationPublishService domPublish = delegates.getInstance(DOMNotificationPublishService.class);
+            return new ForwardedNotificationPublishService(codecReg, domPublish);
+        }
+
+    }
 }
index fc7a742..8ce8da8 100644 (file)
@@ -7,15 +7,20 @@
  */
 package org.opendaylight.controller.md.sal.binding.impl;
 
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableSet;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
+import org.opendaylight.controller.md.sal.dom.api.DOMService;
+import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
 import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory;
 import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
@@ -27,6 +32,14 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 public class ForwardedNotificationService implements NotificationService, AutoCloseable {
 
+    public static final Factory<NotificationService> BUILDER_FACTORY = new Factory<NotificationService>() {
+
+        @Override
+        public BindingDOMAdapterBuilder<NotificationService> newBuilder() {
+            return new Builder();
+        }
+
+    };
     private final BindingNormalizedNodeSerializer codec;
     private final DOMNotificationService domNotifService;
     private final NotificationInvokerFactory notificationInvokerFactory;
@@ -92,4 +105,23 @@ public class ForwardedNotificationService implements NotificationService, AutoCl
         }
     }
 
+    private static class Builder extends BindingDOMAdapterBuilder<NotificationService> {
+
+
+        @Override
+        protected NotificationService createInstance(BindingToNormalizedNodeCodec codec,
+                ClassToInstanceMap<DOMService> delegates) {
+            DOMNotificationService domNotification = delegates.getInstance(DOMNotificationService.class);
+            NotificationInvokerFactory invokerFactory = SingletonHolder.INVOKER_FACTORY;
+            return new ForwardedNotificationService(codec.getCodecFactory(), domNotification, invokerFactory);
+        }
+
+        @Override
+        public Set<? extends Class<? extends DOMService>> getRequiredDelegates() {
+            return ImmutableSet.of(DOMNotificationService.class);
+        }
+
+
+
+    }
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedContainerNode.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedContainerNode.java
new file mode 100644 (file)
index 0000000..9eb4ed7
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2015 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.impl;
+
+import com.google.common.base.Optional;
+import java.util.Collection;
+import java.util.Map;
+import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
+
+/**
+ *
+ * FIXME: Should be this moved to binding-data-codec?
+ *
+ */
+class LazySerializedContainerNode implements ContainerNode {
+
+    private final NodeIdentifier identifier;
+    private final DataObject bindingData;
+
+    private BindingNormalizedNodeCodecRegistry registry;
+    private ContainerNode domData;
+
+    LazySerializedContainerNode(QName identifier, DataObject binding,
+            BindingNormalizedNodeCodecRegistry registry) {
+        this.identifier = new NodeIdentifier(identifier);
+        this.bindingData = binding;
+        this.registry = registry;
+        this.domData = null;
+    }
+
+    @Override
+    public Map<QName, String> getAttributes() {
+        return delegate().getAttributes();
+    }
+
+    private ContainerNode delegate() {
+        if(domData == null) {
+            domData = registry.toNormalizedNodeRpcData(bindingData);
+            registry = null;
+        }
+        return domData;
+    }
+
+    @Override
+    public QName getNodeType() {
+        return delegate().getNodeType();
+    }
+
+    @Override
+    public Collection<DataContainerChild<? extends PathArgument, ?>> getValue() {
+        return delegate().getValue();
+    }
+
+    @Override
+    public NodeIdentifier getIdentifier() {
+        return identifier;
+    }
+
+    @Override
+    public Optional<DataContainerChild<? extends PathArgument, ?>> getChild(PathArgument child) {
+        return delegate().getChild(child);
+    }
+
+    @Override
+    public Object getAttributeValue(QName name) {
+        return delegate().getAttributeValue(name);
+    }
+
+    public DataObject bindingData() {
+        return bindingData;
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedDOMRpcResult.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedDOMRpcResult.java
new file mode 100644 (file)
index 0000000..ab368d7
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2015 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.impl;
+
+import java.util.Collection;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+abstract class LazySerializedDOMRpcResult implements DOMRpcResult {
+
+    private final RpcResult<?> bindingResult;
+
+    LazySerializedDOMRpcResult(final RpcResult<?> bindingResult) {
+        this.bindingResult = bindingResult;
+    }
+
+    static final LazySerializedDOMRpcResult create(final RpcResult<?> bindingResult, final BindingNormalizedNodeCodecRegistry codec) {
+        final Object resultData = bindingResult.getResult();
+
+        if(resultData instanceof DataObject) {
+            return new DataResult(bindingResult,codec);
+
+
+        }
+        return new EmptyDataResult(bindingResult);
+    }
+
+    RpcResult<?> bidningRpcResult() {
+        return bindingResult;
+    }
+
+    @Override
+    public Collection<RpcError> getErrors() {
+        return bindingResult.getErrors();
+    }
+
+
+    private static final class DataResult extends LazySerializedDOMRpcResult {
+
+        private final BindingNormalizedNodeCodecRegistry codec;
+        private NormalizedNode<?, ?> domData;
+
+        public DataResult(final RpcResult<?> bindingResult, final BindingNormalizedNodeCodecRegistry codec) {
+            super(bindingResult);
+            this.codec = codec;
+        }
+
+        @Override
+        public NormalizedNode<?, ?> getResult() {
+            if(domData == null) {
+                domData = codec.toNormalizedNodeRpcData((DataContainer) bidningRpcResult().getResult());
+            }
+            return domData;
+        }
+    }
+
+
+    private static final class EmptyDataResult extends LazySerializedDOMRpcResult {
+
+        public EmptyDataResult(final RpcResult<?> bindingResult) {
+            super(bindingResult);
+        }
+
+        @Override
+        public NormalizedNode<?, ?> getResult() {
+            // FIXME: Should we return something else?
+            return null;
+        }
+
+    }
+
+
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java
new file mode 100644 (file)
index 0000000..61b3232
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2015 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.impl;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+class RpcServiceAdapter implements InvocationHandler {
+
+    interface InvocationDelegate {
+
+        ListenableFuture<RpcResult<?>> invoke(SchemaPath rpc, DataObject dataObject);
+
+    }
+
+    private final RpcService proxy;
+    private final ImmutableMap<Method,SchemaPath> rpcNames;
+    private final Class<? extends RpcService> type;
+    private final InvocationDelegate delegate;
+
+    RpcServiceAdapter(Class<? extends RpcService> type, ImmutableMap<Method, SchemaPath> rpcNames, InvocationDelegate delegate) {
+        this.rpcNames = rpcNames;
+        this.type = type;
+        this.delegate = delegate;
+        this.proxy = (RpcService) Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type}, this);
+    }
+
+    RpcService getProxy() {
+        return proxy;
+    }
+
+    @Override
+    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+
+        SchemaPath rpc = rpcNames.get(method);
+        if(rpc != null) {
+            if(method.getParameterTypes().length == 0) {
+                return delegate.invoke(rpc, null);
+            }
+            if(args.length != 1) {
+                throw new IllegalArgumentException("Input must be provided.");
+            }
+            return delegate.invoke(rpc,(DataObject) args[0]);
+        }
+
+        if(isObjectMethod(method)) {
+            return callObjectMethod(proxy, method, args);
+        }
+        throw new UnsupportedOperationException("Method " + method.toString() + "is unsupported.");
+    }
+
+    private static boolean isObjectMethod(Method m) {
+        switch (m.getName()) {
+        case "toString":
+            return (m.getReturnType() == String.class && m.getParameterTypes().length == 0);
+        case "hashCode":
+            return (m.getReturnType() == int.class && m.getParameterTypes().length == 0);
+        case "equals":
+            return (m.getReturnType() == boolean.class && m.getParameterTypes().length == 1 && m.getParameterTypes()[0] == Object.class);
+        }
+        return false;
+    }
+
+    private Object callObjectMethod(Object self, Method m, Object[] args) {
+        switch (m.getName()) {
+        case "toString":
+            return type.getName() + "$Adapter{delegate=" + delegate.toString()+"}";
+        case "hashCode":
+            return System.identityHashCode(self);
+        case "equals":
+            return (self == args[0]);
+        }
+        return null;
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterBuilder.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterBuilder.java
new file mode 100644 (file)
index 0000000..655a176
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 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.spi;
+
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableClassToInstanceMap;
+import com.google.common.collect.MutableClassToInstanceMap;
+import java.util.Set;
+import org.opendaylight.yangtools.concepts.Builder;
+
+public abstract class AdapterBuilder<T,D> implements Builder<T> {
+
+    private final ClassToInstanceMap<D> delegates = MutableClassToInstanceMap.create();
+
+    public abstract Set<? extends Class<? extends D>> getRequiredDelegates();
+
+    protected abstract T createInstance(ClassToInstanceMap<D> delegates);
+
+    private void checkAllRequiredServices() {
+        for(final Class<? extends D> type : getRequiredDelegates()) {
+            Preconditions.checkState(delegates.get(type) != null, "Requires service %s is not defined.",type);
+        }
+    }
+
+    public final <V extends D>void addDelegate(final Class<V> type,final D impl) {
+        delegates.put(type,impl);
+    }
+
+    @Override
+    public final  T build() {
+        checkAllRequiredServices();
+        return createInstance(ImmutableClassToInstanceMap.<D,D>copyOf(delegates));
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterLoader.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterLoader.java
new file mode 100644 (file)
index 0000000..aea5907
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2015 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.spi;
+
+import com.google.common.base.Optional;
+import com.google.common.cache.CacheLoader;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+public abstract class AdapterLoader<T, D> extends CacheLoader<Class<? extends T>, Optional<T>> {
+
+    @Override
+    public Optional<T> load(final Class<? extends T> key) {
+
+        final AdapterBuilder<? extends T, D> builder = createBuilder(key);
+        for(final Class<? extends D> reqDeleg : builder.getRequiredDelegates()) {
+            final D deleg = getDelegate(reqDeleg);
+            if(deleg != null) {
+                builder.addDelegate(reqDeleg,deleg);
+            } else {
+                return Optional.absent();
+            }
+        }
+        return  Optional.<T>of(builder.build());
+    }
+
+    protected abstract @Nullable D getDelegate(Class<? extends D> reqDeleg);
+
+    protected abstract @Nonnull AdapterBuilder<? extends T, D> createBuilder(Class<? extends T> key) throws IllegalArgumentException;
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/MountPointManagerImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/MountPointManagerImpl.java
deleted file mode 100644 (file)
index c3f46b2..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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.sal.binding.impl;
-
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.Executors;
-import org.opendaylight.controller.md.sal.binding.util.AbstractBindingSalProviderInstance;
-import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
-import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.ListenerRegistry;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MountPointManagerImpl implements MountProviderService {
-
-    public final Logger LOG = LoggerFactory.getLogger(MountPointManagerImpl.class);
-
-    private final ConcurrentMap<InstanceIdentifier<?>, BindingMountPointImpl> mountPoints;
-    private final ListenerRegistry<MountProvisionListener> listeners = ListenerRegistry.create();
-
-    private ListeningExecutorService notificationExecutor;
-    private ListeningExecutorService dataCommitExecutor;
-
-    public MountPointManagerImpl() {
-        mountPoints = new ConcurrentHashMap<>();
-    }
-
-    public ListeningExecutorService getNotificationExecutor() {
-        return notificationExecutor;
-    }
-
-    public void setNotificationExecutor(final ListeningExecutorService notificationExecutor) {
-        this.notificationExecutor = notificationExecutor;
-    }
-
-    public ListeningExecutorService getDataCommitExecutor() {
-        return dataCommitExecutor;
-    }
-
-    public void setDataCommitExecutor(final ListeningExecutorService dataCommitExecutor) {
-        this.dataCommitExecutor = dataCommitExecutor;
-    }
-
-    @Override
-    public synchronized BindingMountPointImpl createMountPoint(final InstanceIdentifier<?> path) {
-        BindingMountPointImpl potential = mountPoints.get(path);
-        if (potential != null) {
-            throw new IllegalStateException("Mount point already exists.");
-        }
-        return createOrGetMountPointImpl(path);
-    }
-
-    @Override
-    public BindingMountPointImpl createOrGetMountPoint(final InstanceIdentifier<?> path) {
-        BindingMountPointImpl potential = getMountPoint(path);
-        if (potential != null) {
-            return potential;
-        }
-        return createOrGetMountPointImpl(path);
-    }
-
-    @Override
-    public BindingMountPointImpl getMountPoint(final InstanceIdentifier<?> path) {
-        return mountPoints.get(path);
-    }
-
-    private synchronized BindingMountPointImpl createOrGetMountPointImpl(final InstanceIdentifier<?> path) {
-        BindingMountPointImpl potential = getMountPoint(path);
-        if (potential != null) {
-            return potential;
-        }
-        RpcProviderRegistryImpl rpcRegistry = new RpcProviderRegistryImpl("mount");
-        NotificationBrokerImpl notificationBroker = new NotificationBrokerImpl(getNotificationExecutor());
-        DataBrokerImpl dataBroker = new DataBrokerImpl();
-        dataBroker.setExecutor(MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()));
-        BindingMountPointImpl mountInstance = new BindingMountPointImpl(path, rpcRegistry, notificationBroker,
-                dataBroker);
-        mountPoints.putIfAbsent(path, mountInstance);
-        notifyMountPointCreated(path);
-        return mountInstance;
-    }
-
-    private void notifyMountPointCreated(final InstanceIdentifier<?> path) {
-        for (ListenerRegistration<MountProvisionListener> listener : listeners) {
-            try {
-                listener.getInstance().onMountPointCreated(path);
-            } catch (Exception e) {
-                LOG.error("Unhandled exception during invoking listener.", e);
-            }
-        }
-    }
-
-    @Override
-    public ListenerRegistration<MountProvisionListener> registerProvisionListener(final MountProvisionListener listener) {
-        return listeners.register(listener);
-    }
-
-    public class BindingMountPointImpl extends
-    AbstractBindingSalProviderInstance<DataBrokerImpl, NotificationBrokerImpl, RpcProviderRegistryImpl>
-    implements MountProviderInstance {
-
-        private final InstanceIdentifier<?> identifier;
-
-        public BindingMountPointImpl(final InstanceIdentifier<?> identifier,
-                final RpcProviderRegistryImpl rpcRegistry, final NotificationBrokerImpl notificationBroker,
-                final DataBrokerImpl dataBroker) {
-            super(rpcRegistry, notificationBroker, dataBroker);
-            this.identifier = identifier;
-        }
-
-        // Needed only for BI Connector
-        public DataBrokerImpl getDataBrokerImpl() {
-            return getDataBroker();
-        }
-
-        @Override
-        public InstanceIdentifier<?> getIdentifier() {
-            return this.identifier;
-        }
-    }
-}
index ddfb1cd..193f3c8 100644 (file)
@@ -9,7 +9,9 @@ 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.util.AbstractBindingSalProviderInstance;
 import org.opendaylight.controller.md.sal.binding.util.BindingContextUtils;
 import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
@@ -35,8 +37,6 @@ import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.ImmutableClassToInstanceMap;
-
 public class RootBindingAwareBroker implements //
         Mutable, //
         Identifiable<String>, //
@@ -52,27 +52,25 @@ public class RootBindingAwareBroker implements //
 
     private NotificationProviderService notificationBroker;
 
+    @SuppressWarnings("deprecation")
     private DataProviderService legacyDataBroker;
 
     private DataBroker dataBroker;
 
-    private MountPointManagerImpl mountManager;
-
-    public MountPointManagerImpl getMountManager() {
-        return mountManager;
-    }
-
-    public void setMountManager(final MountPointManagerImpl mountManager) {
-        this.mountManager = mountManager;
-    }
+    private MountProviderService legacyMount;
 
     private ImmutableClassToInstanceMap<BindingAwareService> supportedConsumerServices;
 
     private ImmutableClassToInstanceMap<BindingAwareService> supportedProviderServices;
 
+    private MountPointService mountService;
+
+    public void setLegacyMountManager(final MountProviderService legacyMount) {
+        this.legacyMount = legacyMount;
+    }
+
     public RootBindingAwareBroker(final String instanceName) {
         this.identifier = instanceName;
-        mountManager = new MountPointManagerImpl();
     }
 
     @Override
@@ -100,6 +98,22 @@ public class RootBindingAwareBroker implements //
         return rpcBroker;
     }
 
+    public MountPointService getMountService() {
+        return mountService;
+    }
+
+    public MountProviderService getLegacyMount() {
+        return legacyMount;
+    }
+
+    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;
     }
@@ -118,31 +132,31 @@ public class RootBindingAwareBroker implements //
 
         controllerRoot = new RootSalInstance(getRpcProviderRegistry(), getNotificationBroker(), getDataBroker());
 
-        ImmutableClassToInstanceMap.Builder<BindingAwareService> consBuilder = ImmutableClassToInstanceMap.builder();
+        final ImmutableClassToInstanceMap.Builder<BindingAwareService> consBuilder = ImmutableClassToInstanceMap
+                .builder();
 
         consBuilder.put(NotificationService.class, getRoot());
         consBuilder.put(DataBrokerService.class, getRoot());
         consBuilder.put(RpcConsumerRegistry.class, getRoot());
-        if(dataBroker != null) {
+        if (dataBroker != null) {
             consBuilder.put(DataBroker.class, dataBroker);
         }
-        consBuilder.put(MountService.class, mountManager).build();
+        consBuilder.put(MountPointService.class, mountService);
+        consBuilder.put(MountService.class, legacyMount).build();
         supportedConsumerServices = consBuilder.build();
         supportedProviderServices = ImmutableClassToInstanceMap.<BindingAwareService> builder()
                 .putAll(supportedConsumerServices).put(NotificationProviderService.class, getRoot())
                 .put(DataProviderService.class, getRoot()).put(RpcProviderRegistry.class, getRoot())
-                .put(MountProviderService.class, mountManager).build();
+                .put(MountProviderService.class, legacyMount).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(BindingAwareProvider provider,
-            BundleContext ctx) {
+    public ProviderContext registerProvider(final BindingAwareProvider provider, final BundleContext ctx) {
         return registerProvider(provider);
     }
 
@@ -195,7 +209,4 @@ public class RootBindingAwareBroker implements //
         }
     }
 
-    public void setDataBroker(final DataBroker asyncDataBroker) {
-        dataBroker = asyncDataBroker;
-    }
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingDomConnectorDeployer.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingDomConnectorDeployer.java
deleted file mode 100644 (file)
index bfafc1f..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2013 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.sal.binding.impl.connect.dom;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
-import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
-import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService;
-
-public class BindingDomConnectorDeployer {
-
-    private static BindingIndependentMappingService mappingService;
-
-    public static BindingIndependentConnector tryToDeployConnector(RootBindingAwareBroker baBroker,
-            ProviderSession domSession) {
-        checkNotNull(baBroker);
-        checkNotNull(domSession);
-        BindingIndependentConnector connector = createConnector(mappingService);
-        return connector;
-    }
-
-    public static BindingIndependentConnector createConnector(BindingIndependentMappingService mappingService) {
-        BindingIndependentConnector connector = new BindingIndependentConnector();
-        connector.setMappingService(mappingService);
-        return connector;
-    }
-
-    public static BindingIndependentConnector createConnector(BindingIndependentConnector source) {
-        BindingIndependentConnector connector = new BindingIndependentConnector();
-        connector.setMappingService(source.getMappingService());
-        return connector;
-    }
-
-    public static void startDataForwarding(BindingIndependentConnector connector, DataProviderService baService,
-            ProviderSession domContext) {
-        startDataForwarding(connector, baService,
-                domContext.getService(org.opendaylight.controller.sal.core.api.data.DataProviderService.class));
-    }
-
-    public static void startRpcForwarding(BindingIndependentConnector connector,
-            RpcProviderRegistry rpcProviderRegistry, ProviderSession domProviderContext) {
-        startRpcForwarding(connector, rpcProviderRegistry, domProviderContext.getService(RpcProvisionRegistry.class));
-
-    }
-
-    public static void startNotificationForwarding(BindingIndependentConnector connector, NotificationProviderService provider,ProviderSession domProviderContext) {
-        startNotificationForwarding(connector, provider, domProviderContext.getService(NotificationPublishService.class));
-    }
-
-    public static void startRpcForwarding(BindingIndependentConnector connector, RpcProviderRegistry baService,
-            RpcProvisionRegistry domService) {
-        if (connector.isRpcForwarding()) {
-            return;
-        }
-
-        connector.setDomRpcRegistry(domService);
-        connector.setBindingRpcRegistry(baService);
-        connector.startRpcForwarding();
-    }
-
-    public static void startDataForwarding(BindingIndependentConnector connector, DataProviderService baService,
-            org.opendaylight.controller.sal.core.api.data.DataProviderService domService) {
-        if (connector.isDataForwarding()) {
-            return;
-        }
-
-        connector.setBindingDataService(baService);
-        connector.setDomDataService(domService);
-        connector.startDataForwarding();
-    }
-
-    public static void startNotificationForwarding(BindingIndependentConnector connector,
-            NotificationProviderService baService, NotificationPublishService domService) {
-        if(connector.isNotificationForwarding()) {
-            return;
-        }
-        connector.setBindingNotificationService(baService);
-        connector.setDomNotificationService(domService);
-        connector.startNotificationForwarding();
-    }
-
-    //
-    // public static BindingIndependentMappingService getGlobalMappingService()
-    // {
-    // return mappingService;
-    // }
-    //
-    // protected static BindingIndependentMappingService
-    // setGlobalMappingService(BindingIndependentMappingService service) {
-    // mappingService= service;
-    // return mappingService;
-    // }
-    //
-    // public static BindingIndependentConnector
-    // tryToDeployConnector(MountProviderInstance baMount,MountProvisionInstance
-    // domMount) {
-    //
-    //
-    // return null;
-    // }
-
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java
deleted file mode 100644 (file)
index f63ce10..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright (c) 2013 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.sal.binding.impl.connect.dom;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.opendaylight.controller.md.sal.binding.impl.AbstractForwardedDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.DataReader;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;
-import org.opendaylight.controller.sal.binding.impl.MountPointManagerImpl.BindingMountPointImpl;
-import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
-import org.opendaylight.controller.sal.core.api.Provider;
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
-import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.Augmentable;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
-import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class BindingIndependentConnector implements //
-        DataReader<InstanceIdentifier<? extends DataObject>, DataObject>, //
-        Provider, //
-        AutoCloseable {
-
-    private static final Logger LOG = LoggerFactory.getLogger(BindingIndependentConnector.class);
-    private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier ROOT_BI = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier
-            .builder().toInstance();
-
-    private BindingIndependentMappingService mappingService;
-    private org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService;
-    private DataProviderService baDataService;
-
-    private final ConcurrentMap<Object, BindingToDomTransaction> domOpenedTransactions;
-    private final ConcurrentMap<Object, DomToBindingTransaction> bindingOpenedTransactions;
-    private final BindingToDomCommitHandler bindingToDomCommitHandler;
-    private final DomToBindingCommitHandler domToBindingCommitHandler;
-
-    private Registration biCommitHandlerRegistration;
-    private RpcProvisionRegistry biRpcRegistry;
-    private RpcProviderRegistry baRpcRegistry;
-
-    private ListenerRegistration<DomToBindingRpcForwardingManager> domToBindingRpcManager;
-
-    private boolean rpcForwarding;
-    private boolean dataForwarding;
-    private boolean notificationForwarding;
-
-    private RpcProviderRegistryImpl baRpcRegistryImpl;
-
-    private NotificationProviderService baNotifyService;
-
-    private NotificationPublishService domNotificationService;
-
-    public BindingIndependentConnector() {
-        domOpenedTransactions = new ConcurrentHashMap<>();
-        bindingOpenedTransactions = new ConcurrentHashMap<>();
-
-        bindingToDomCommitHandler = new BindingToDomCommitHandler(bindingOpenedTransactions, domOpenedTransactions);
-        domToBindingCommitHandler = new DomToBindingCommitHandler(bindingOpenedTransactions, domOpenedTransactions);
-        rpcForwarding = false;
-        dataForwarding = false;
-        notificationForwarding = false;
-    }
-
-    @Override
-    public DataObject readOperationalData(final InstanceIdentifier<? extends DataObject> path) {
-        try {
-            org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biPath = mappingService.toDataDom(path);
-            CompositeNode result = biDataService.readOperationalData(biPath);
-            return potentialAugmentationRead(path, biPath, result);
-        } catch (DeserializationException e) {
-            throw new IllegalStateException(e);
-        }
-    }
-
-    private DataObject potentialAugmentationRead(InstanceIdentifier<? extends DataObject> path,
-            final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biPath, final CompositeNode result)
-            throws DeserializationException {
-        Class<? extends DataObject> targetType = path.getTargetType();
-        if (Augmentation.class.isAssignableFrom(targetType)) {
-            path = mappingService.fromDataDom(biPath);
-            Class<? extends Augmentation<?>> augmentType = (Class<? extends Augmentation<?>>) targetType;
-            DataObject parentTo = mappingService.dataObjectFromDataDom(path, result);
-            if (parentTo instanceof Augmentable<?>) {
-                return (DataObject) ((Augmentable) parentTo).getAugmentation(augmentType);
-            }
-        }
-        return mappingService.dataObjectFromDataDom(path, result);
-    }
-
-    @Override
-    public DataObject readConfigurationData(final InstanceIdentifier<? extends DataObject> path) {
-        try {
-            org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biPath = mappingService.toDataDom(path);
-            CompositeNode result = biDataService.readConfigurationData(biPath);
-            return potentialAugmentationRead(path, biPath, result);
-        } catch (DeserializationException e) {
-            throw new IllegalStateException(e);
-        }
-    }
-
-    public org.opendaylight.controller.sal.core.api.data.DataProviderService getBiDataService() {
-        return biDataService;
-    }
-
-    protected void setDomDataService(
-            final org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService) {
-        this.biDataService = biDataService;
-        bindingToDomCommitHandler.setBindingIndependentDataService(this.biDataService);
-    }
-
-    public DataProviderService getBaDataService() {
-        return baDataService;
-    }
-
-    protected void setBindingDataService(final DataProviderService baDataService) {
-        this.baDataService = baDataService;
-        domToBindingCommitHandler.setBindingAwareDataService(this.baDataService);
-    }
-
-    public RpcProviderRegistry getRpcRegistry() {
-        return baRpcRegistry;
-    }
-
-    protected void setBindingRpcRegistry(final RpcProviderRegistry rpcRegistry) {
-        this.baRpcRegistry = rpcRegistry;
-    }
-
-    public void startDataForwarding() {
-        if (baDataService instanceof AbstractForwardedDataBroker) {
-            dataForwarding = true;
-            return;
-        }
-
-        final DataProviderService baData;
-        if (baDataService instanceof BindingMountPointImpl) {
-            baData = ((BindingMountPointImpl) baDataService).getDataBrokerImpl();
-            LOG.debug("Extracted BA Data provider {} from mount point {}", baData, baDataService);
-        } else {
-            baData = baDataService;
-        }
-
-        if (baData instanceof DataBrokerImpl) {
-            checkState(!dataForwarding, "Connector is already forwarding data.");
-            ((DataBrokerImpl) baData).setDataReadDelegate(this);
-            ((DataBrokerImpl) baData).setRootCommitHandler(bindingToDomCommitHandler);
-            biCommitHandlerRegistration = biDataService.registerCommitHandler(ROOT_BI, domToBindingCommitHandler);
-            baDataService.registerCommitHandlerListener(domToBindingCommitHandler);
-        }
-
-        dataForwarding = true;
-    }
-
-    //WTF? - cycle references to biFwdManager - need to solve :-/
-    public void startRpcForwarding() {
-        checkNotNull(mappingService, "Unable to start Rpc forwarding. Reason: Mapping Service is not initialized properly!");
-        if (biRpcRegistry != null && baRpcRegistry instanceof RouteChangePublisher<?, ?>) {
-            checkState(!rpcForwarding, "Connector is already forwarding RPCs");
-            final DomToBindingRpcForwardingManager biFwdManager = new DomToBindingRpcForwardingManager(mappingService, biRpcRegistry, baRpcRegistry);
-
-            domToBindingRpcManager = baRpcRegistry.registerRouteChangeListener(biFwdManager);
-            biRpcRegistry.addRpcRegistrationListener(biFwdManager);
-            if (baRpcRegistry instanceof RpcProviderRegistryImpl) {
-                baRpcRegistryImpl = (RpcProviderRegistryImpl) baRpcRegistry;
-                baRpcRegistryImpl.registerRouterInstantiationListener(domToBindingRpcManager.getInstance());
-                baRpcRegistryImpl.registerGlobalRpcRegistrationListener(domToBindingRpcManager.getInstance());
-                biFwdManager.setRegistryImpl(baRpcRegistryImpl);
-            }
-            rpcForwarding = true;
-        }
-    }
-
-    public void startNotificationForwarding() {
-        checkState(!notificationForwarding, "Connector is already forwarding notifications.");
-        if (mappingService == null) {
-            LOG.warn("Unable to start Notification forwarding. Reason: Mapping Service is not initialized properly!");
-        } else if (baNotifyService == null) {
-            LOG.warn("Unable to start Notification forwarding. Reason: Binding Aware Notify Service is not initialized properly!");
-        } else if (domNotificationService == null) {
-            LOG.warn("Unable to start Notification forwarding. Reason: DOM Notification Service is not initialized properly!");
-        } else {
-            baNotifyService.registerInterestListener(
-                new DomToBindingNotificationForwarder(mappingService, baNotifyService, domNotificationService));
-            notificationForwarding = true;
-        }
-    }
-
-    protected void setMappingService(final BindingIndependentMappingService mappingService) {
-        this.mappingService = mappingService;
-        bindingToDomCommitHandler.setMappingService(this.mappingService);
-        domToBindingCommitHandler.setMappingService(this.mappingService);
-    }
-
-    @Override
-    public Collection<ProviderFunctionality> getProviderFunctionality() {
-        return Collections.emptyList();
-    }
-
-    @Override
-    public void onSessionInitiated(final ProviderSession session) {
-        setDomDataService(session.getService(org.opendaylight.controller.sal.core.api.data.DataProviderService.class));
-        setDomRpcRegistry(session.getService(RpcProvisionRegistry.class));
-
-    }
-
-    public void setDomRpcRegistry(final RpcProvisionRegistry registry) {
-        biRpcRegistry = registry;
-    }
-
-    @Override
-    public void close() throws Exception {
-        if (biCommitHandlerRegistration != null) {
-            biCommitHandlerRegistration.close();
-        }
-    }
-
-    public boolean isRpcForwarding() {
-        return rpcForwarding;
-    }
-
-    public boolean isDataForwarding() {
-        return dataForwarding;
-    }
-
-    public boolean isNotificationForwarding() {
-        return notificationForwarding;
-    }
-
-    public BindingIndependentMappingService getMappingService() {
-        return mappingService;
-    }
-
-    public void setBindingNotificationService(final NotificationProviderService baService) {
-        this.baNotifyService = baService;
-
-    }
-
-    public void setDomNotificationService(final NotificationPublishService domService) {
-        this.domNotificationService = domService;
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingToDomCommitHandler.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingToDomCommitHandler.java
deleted file mode 100644 (file)
index 44198bf..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.connect.dom;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentMap;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.controller.sal.common.util.CommitHandlerTransactions;
-import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction;
-import org.opendaylight.controller.sal.core.api.data.DataProviderService;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @deprecated This is part of the legacy DataBrokerService
- */
-@Deprecated
-class BindingToDomCommitHandler implements
-    DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> {
-
-    private final Logger LOG = LoggerFactory.getLogger(BindingToDomCommitHandler.class);
-
-    private final ConcurrentMap<Object, DomToBindingTransaction> bindingOpenedTransactions;
-    private final ConcurrentMap<Object, BindingToDomTransaction> domOpenedTransactions;
-    private org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService;
-    private BindingIndependentMappingService mappingService;
-
-    BindingToDomCommitHandler(final ConcurrentMap<Object, DomToBindingTransaction> bindingOpenedTransactions,
-        final ConcurrentMap<Object, BindingToDomTransaction> domOpenedTransactions) {
-        this.bindingOpenedTransactions = bindingOpenedTransactions;
-        this.domOpenedTransactions = domOpenedTransactions;
-    }
-
-    public void setBindingIndependentDataService(final DataProviderService biDataService) {
-        this.biDataService = biDataService;
-    }
-
-    public void setMappingService(final BindingIndependentMappingService mappingService) {
-        this.mappingService = mappingService;
-    }
-
-    @Override
-    public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> requestCommit(
-        final DataModification<InstanceIdentifier<? extends DataObject>, DataObject> bindingTransaction) {
-
-        /**
-         * Transaction was created as DOM transaction, in that case we do
-         * not need to forward it back.
-         */
-        if (bindingOpenedTransactions.containsKey(bindingTransaction.getIdentifier())) {
-            return CommitHandlerTransactions.allwaysSuccessfulTransaction(bindingTransaction);
-        }
-        DataModificationTransaction domTransaction = createBindingToDomTransaction(bindingTransaction);
-        BindingToDomTransaction wrapped = new BindingToDomTransaction(domTransaction, bindingTransaction, domOpenedTransactions);
-        LOG.trace("Forwarding Binding Transaction: {} as DOM Transaction: {} .",
-            bindingTransaction.getIdentifier(), domTransaction.getIdentifier());
-        return wrapped;
-    }
-
-    private DataModificationTransaction createBindingToDomTransaction(
-        final DataModification<InstanceIdentifier<? extends DataObject>, DataObject> source) {
-        if (biDataService == null) {
-            final String msg = "Binding Independent Service is not initialized correctly! Binding to DOM Transaction cannot be created for ";
-            LOG.error(msg + "{}", source);
-            throw new IllegalStateException(msg + source);
-        }
-        if (mappingService == null) {
-            final String msg = "Mapping Service is not initialized correctly! Binding to DOM Transaction cannot be created for ";
-            LOG.error(msg + "{}", source);
-            throw new IllegalStateException(msg + source);
-        }
-        DataModificationTransaction target = biDataService.beginTransaction();
-        LOG.debug("Created DOM Transaction {} for {},", target.getIdentifier(), source.getIdentifier());
-        for (InstanceIdentifier<? extends DataObject> entry : source.getRemovedConfigurationData()) {
-            org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biEntry = mappingService.toDataDom(entry);
-            target.removeConfigurationData(biEntry);
-            LOG.debug("Delete of Binding Configuration Data {} is translated to {}", entry, biEntry);
-        }
-        for (InstanceIdentifier<? extends DataObject> entry : source.getRemovedOperationalData()) {
-            org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biEntry = mappingService.toDataDom(entry);
-            target.removeOperationalData(biEntry);
-            LOG.debug("Delete of Binding Operational Data {} is translated to {}", entry, biEntry);
-        }
-        for (Map.Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry : source.getUpdatedConfigurationData()
-            .entrySet()) {
-            Map.Entry<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> biEntry = mappingService
-                .toDataDom(entry);
-            target.putConfigurationData(biEntry.getKey(), biEntry.getValue());
-            LOG.debug("Update of Binding Configuration Data {} is translated to {}", entry, biEntry);
-        }
-        for (Map.Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry : source.getUpdatedOperationalData()
-            .entrySet()) {
-            Map.Entry<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> biEntry = mappingService
-                .toDataDom(entry);
-            target.putOperationalData(biEntry.getKey(), biEntry.getValue());
-            LOG.debug("Update of Binding Operational Data {} is translated to {}", entry, biEntry);
-        }
-        return target;
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingToDomTransaction.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingToDomTransaction.java
deleted file mode 100644 (file)
index 3c8e787..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.connect.dom;
-
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-
-@Deprecated
-class BindingToDomTransaction implements
-    DataCommitHandler.DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> {
-
-    private final DataModificationTransaction backing;
-    private final DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification;
-    private final ConcurrentMap<Object, BindingToDomTransaction> domOpenedTransactions;
-
-    public BindingToDomTransaction(final DataModificationTransaction backing,
-        final DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification,
-        ConcurrentMap<Object, BindingToDomTransaction> domOpenedTransactions) {
-        this.backing = backing;
-        this.modification = modification;
-        this.domOpenedTransactions = domOpenedTransactions;
-        this.domOpenedTransactions.put(backing.getIdentifier(), this);
-    }
-
-    @Override
-    public DataModification<InstanceIdentifier<? extends DataObject>, DataObject> getModification() {
-        return modification;
-    }
-
-    @Override
-    public RpcResult<Void> finish() throws IllegalStateException {
-        Future<RpcResult<TransactionStatus>> result = backing.commit();
-        try {
-            RpcResult<TransactionStatus> biResult = result.get();
-            domOpenedTransactions.remove(backing.getIdentifier());
-            return RpcResultBuilder.<Void> status(biResult.isSuccessful())
-                                             .withRpcErrors(biResult.getErrors()).build();
-        } catch (InterruptedException e) {
-            throw new IllegalStateException("", e);
-        } catch (ExecutionException e) {
-            throw new IllegalStateException("", e);
-        } finally {
-            domOpenedTransactions.remove(backing.getIdentifier());
-        }
-    }
-
-    @Override
-    public RpcResult<Void> rollback() throws IllegalStateException {
-        domOpenedTransactions.remove(backing.getIdentifier());
-        return RpcResultBuilder.<Void> success().build();
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingCommitHandler.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingCommitHandler.java
deleted file mode 100644 (file)
index 43334f0..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.connect.dom;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentMap;
-
-import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration;
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.controller.sal.common.util.CommitHandlerTransactions;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
-import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @deprecated This is part of the legacy DataBrokerService
- */
-@Deprecated
-class DomToBindingCommitHandler implements //
-    RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject>>, //
-    DataCommitHandler<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> {
-
-    private final Logger LOG = LoggerFactory.getLogger(DomToBindingCommitHandler.class);
-
-    private final ConcurrentMap<Object, DomToBindingTransaction> bindingOpenedTransactions;
-    private final ConcurrentMap<Object, BindingToDomTransaction> domOpenedTransactions;
-
-    DomToBindingCommitHandler(final ConcurrentMap<Object, DomToBindingTransaction> bindingOpenedTransactions,
-        final ConcurrentMap<Object, BindingToDomTransaction> domOpenedTransactions) {
-        this.bindingOpenedTransactions = bindingOpenedTransactions;
-        this.domOpenedTransactions = domOpenedTransactions;
-    }
-
-    private DataProviderService baDataService;
-    private BindingIndependentMappingService mappingService;
-
-    public void setBindingAwareDataService(final DataProviderService baDataService) {
-        this.baDataService = baDataService;
-    }
-
-    public void setMappingService(final BindingIndependentMappingService mappingService) {
-        this.mappingService = mappingService;
-    }
-
-    @Override
-    public void onRegister(final DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject> registration) {
-        mappingService.toDataDom(registration.getPath());
-    }
-
-    @Override
-    public void onUnregister(
-        final DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject> registration) {
-        // NOOP for now
-        // FIXME: do registration based on only active commit handlers.
-    }
-
-    @Override
-    public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> requestCommit(
-        final DataModification<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> domTransaction) {
-        Object identifier = domTransaction.getIdentifier();
-
-        /**
-         * We checks if the transcation was originated in this mapper. If it
-         * was originated in this mapper we are returing allways success
-         * commit hanlder to prevent creating loop in two-phase commit and
-         * duplicating data.
-         */
-        if (domOpenedTransactions.containsKey(identifier)) {
-            return CommitHandlerTransactions.allwaysSuccessfulTransaction(domTransaction);
-        }
-
-        org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction baTransaction = createDomToBindingTransaction(domTransaction);
-        DomToBindingTransaction forwardedTransaction = new DomToBindingTransaction(baTransaction, domTransaction, bindingOpenedTransactions);
-        LOG.trace("Forwarding DOM Transaction: {} as Binding Transaction: {}.", domTransaction.getIdentifier(),
-            baTransaction.getIdentifier());
-        return forwardedTransaction;
-    }
-
-    private org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction createDomToBindingTransaction(
-        final DataModification<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> source) {
-        if (baDataService == null) {
-            final String msg = "Binding Aware Service is not initialized correctly! DOM to Binding Transaction cannot be created for ";
-            LOG.error(msg + "{}", source);
-            throw new IllegalStateException(msg + source);
-        }
-        if (mappingService == null) {
-            final String msg = "Mapping Service is not initialized correctly! DOM to Binding Transaction cannot be created for ";
-            LOG.error(msg + "{}", source);
-            throw new IllegalStateException(msg + source);
-        }
-
-        org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction target = baDataService
-            .beginTransaction();
-        for (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier entry : source.getRemovedConfigurationData()) {
-            try {
-
-                InstanceIdentifier<?> baEntry = mappingService.fromDataDom(entry);
-                target.removeConfigurationData(baEntry);
-            } catch (DeserializationException e) {
-                LOG.error("Ommiting from BA transaction: {}.", entry, e);
-            }
-        }
-        for (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier entry : source.getRemovedOperationalData()) {
-            try {
-
-                InstanceIdentifier<?> baEntry = mappingService.fromDataDom(entry);
-                target.removeOperationalData(baEntry);
-            } catch (DeserializationException e) {
-                LOG.error("Ommiting from BA transaction: {}.", entry, e);
-            }
-        }
-        for (Map.Entry<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> entry : source
-            .getUpdatedConfigurationData().entrySet()) {
-            try {
-                InstanceIdentifier<?> baKey = mappingService.fromDataDom(entry.getKey());
-                DataObject baData = mappingService.dataObjectFromDataDom(baKey, entry.getValue());
-                target.putConfigurationData(baKey, baData);
-            } catch (DeserializationException e) {
-                LOG.error("Ommiting from BA transaction: {}.", entry.getKey(), e);
-            }
-        }
-        for (Map.Entry<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> entry : source
-            .getUpdatedOperationalData().entrySet()) {
-            try {
-
-                InstanceIdentifier<?> baKey = mappingService.fromDataDom(entry.getKey());
-                DataObject baData = mappingService.dataObjectFromDataDom(baKey, entry.getValue());
-                target.putOperationalData(baKey, baData);
-            } catch (DeserializationException e) {
-                LOG.error("Ommiting from BA transaction: {}.", entry.getKey(), e);
-            }
-        }
-        return target;
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingNotificationForwarder.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingNotificationForwarder.java
deleted file mode 100644 (file)
index 841ea55..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.connect.dom;
-
-import java.lang.ref.WeakReference;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.core.api.notify.NotificationListener;
-import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
-
-class DomToBindingNotificationForwarder implements NotificationProviderService.NotificationInterestListener,
-    NotificationListener {
-
-    private final ConcurrentMap<QName, WeakReference<Class<? extends Notification>>> notifications = new ConcurrentHashMap<>();
-    private final Set<QName> supportedNotifications = new HashSet<>();
-
-    private final BindingIndependentMappingService mappingService;
-    private final NotificationProviderService baNotifyService;
-    private final NotificationPublishService domNotificationService;
-
-    DomToBindingNotificationForwarder(final BindingIndependentMappingService mappingService, final NotificationProviderService baNotifyService,
-        final NotificationPublishService domNotificationService) {
-        this.mappingService = mappingService;
-        this.baNotifyService = baNotifyService;
-        this.domNotificationService = domNotificationService;
-    }
-
-    @Override
-    public Set<QName> getSupportedNotifications() {
-        return Collections.unmodifiableSet(supportedNotifications);
-    }
-
-    @Override
-    public void onNotification(final CompositeNode notification) {
-        QName qname = notification.getNodeType();
-        WeakReference<Class<? extends Notification>> potential = notifications.get(qname);
-        if (potential != null) {
-            Class<? extends Notification> potentialClass = potential.get();
-            if (potentialClass != null) {
-                final DataContainer baNotification = mappingService.dataObjectFromDataDom(potentialClass,
-                    notification);
-
-                if (baNotification instanceof Notification) {
-                    baNotifyService.publish((Notification) baNotification);
-                }
-            }
-        }
-    }
-
-    @Override
-    public void onNotificationSubscribtion(final Class<? extends Notification> notificationType) {
-        QName qname = BindingReflections.findQName(notificationType);
-        if (qname != null) {
-            WeakReference<Class<? extends Notification>> already = notifications.putIfAbsent(qname,
-                new WeakReference<Class<? extends Notification>>(notificationType));
-            if (already == null) {
-                domNotificationService.addNotificationListener(qname, this);
-                supportedNotifications.add(qname);
-            }
-        }
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingRpcForwarder.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingRpcForwarder.java
deleted file mode 100644 (file)
index 9bff0e9..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.connect.dom;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkState;
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-import java.util.concurrent.Callable;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
-import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;
-import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.core.api.RpcImplementation;
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.util.ClassLoaderUtils;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.BindingMapping;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-class DomToBindingRpcForwarder implements RpcImplementation, InvocationHandler {
-
-    private final Logger LOG = LoggerFactory.getLogger(DomToBindingRpcForwarder.class);
-
-    private final Set<QName> supportedRpcs;
-    private final WeakReference<Class<? extends RpcService>> rpcServiceType;
-    private Set<RoutedRpcRegistration> registrations;
-    private final Map<QName, RpcInvocationStrategy> strategiesByQName = new HashMap<>();
-    private final WeakHashMap<Method, RpcInvocationStrategy> strategiesByMethod = new WeakHashMap<>();
-    private final RpcService proxy;
-    private ObjectRegistration<?> forwarderRegistration;
-    private boolean registrationInProgress = false;
-
-    private final RpcProvisionRegistry biRpcRegistry;
-    private final RpcProviderRegistry baRpcRegistry;
-    private final RpcProviderRegistryImpl baRpcRegistryImpl;
-
-    private final Function<InstanceIdentifier<?>, YangInstanceIdentifier> toDOMInstanceIdentifier;
-
-    private final static Method EQUALS_METHOD;
-
-    static {
-        try {
-            EQUALS_METHOD = Object.class.getMethod("equals", Object.class);
-        } catch (NoSuchMethodException | SecurityException e) {
-            throw new ExceptionInInitializerError(e);
-        }
-    }
-
-    public DomToBindingRpcForwarder(final Class<? extends RpcService> service, final BindingIndependentMappingService mappingService,
-        final RpcProvisionRegistry biRpcRegistry, final RpcProviderRegistry baRpcRegistry, final RpcProviderRegistryImpl registryImpl) {
-        this.rpcServiceType = new WeakReference<Class<? extends RpcService>>(service);
-        this.supportedRpcs = mappingService.getRpcQNamesFor(service);
-
-        this.toDOMInstanceIdentifier = new Function<InstanceIdentifier<?>, YangInstanceIdentifier>() {
-            @Override
-            public YangInstanceIdentifier apply(final InstanceIdentifier<?> input) {
-                return mappingService.toDataDom(input);
-            }
-        };
-
-        this.biRpcRegistry = biRpcRegistry;
-        this.baRpcRegistry = baRpcRegistry;
-        this.baRpcRegistryImpl = registryImpl;
-
-        Class<?> cls = rpcServiceType.get();
-        ClassLoader clsLoader = cls.getClassLoader();
-        proxy =(RpcService) Proxy.newProxyInstance(clsLoader, new Class<?>[] { cls }, this);
-        createStrategies(mappingService);
-    }
-
-    /**
-     * Constructor for Routed RPC Forwarder.
-     *
-     * @param service
-     * @param context
-     * @param registryImpl
-     */
-    public DomToBindingRpcForwarder(final Class<? extends RpcService> service,
-        final Class<? extends BaseIdentity> context, final BindingIndependentMappingService mappingService,
-        final RpcProvisionRegistry biRpcRegistry, final RpcProviderRegistry baRpcRegistry, final RpcProviderRegistryImpl registryImpl) {
-        this(service, mappingService, biRpcRegistry, baRpcRegistry,registryImpl);
-
-        final ImmutableSet.Builder<RoutedRpcRegistration> registrationsBuilder = ImmutableSet.builder();
-        try {
-            for (QName rpc : supportedRpcs) {
-                registrationsBuilder.add(biRpcRegistry.addRoutedRpcImplementation(rpc, this));
-            }
-            createDefaultDomForwarder();
-        } catch (Exception e) {
-            LOG.error("Could not forward Rpcs of type {}", service.getName(), e);
-        }
-        registrations = registrationsBuilder.build();
-    }
-
-
-
-    private void createStrategies(final BindingIndependentMappingService mappingService) {
-        try {
-            for (QName rpc : supportedRpcs) {
-                RpcInvocationStrategy strategy = createInvocationStrategy(rpc, rpcServiceType.get(), mappingService);
-                strategiesByMethod.put(strategy.targetMethod, strategy);
-                strategiesByQName.put(rpc, strategy);
-            }
-        } catch (Exception e) {
-            LOG.error("Could not forward Rpcs of type {}", rpcServiceType.get(), e);
-        }
-
-    }
-
-    /**
-     * Registers RPC Forwarder to DOM Broker,
-     * this means Binding Aware Broker has implementation of RPC
-     * which is registered to it.
-     *
-     * If RPC Forwarder was previously registered to DOM Broker
-     * or to Bidning Broker this method is noop to prevent
-     * creating forwarding loop.
-     *
-     */
-    public void registerToDOMBroker() {
-        if(!registrationInProgress && forwarderRegistration == null) {
-            registrationInProgress = true;
-            CompositeObjectRegistration.CompositeObjectRegistrationBuilder<DomToBindingRpcForwarder> builder = CompositeObjectRegistration.builderFor(this);
-            try {
-                for (QName rpc : supportedRpcs) {
-                    builder.add(biRpcRegistry.addRpcImplementation(rpc, this));
-                }
-            } catch (Exception e) {
-                LOG.error("Could not forward Rpcs of type {}", rpcServiceType.get(), e);
-            }
-            this.forwarderRegistration = builder.toInstance();
-            registrationInProgress = false;
-        }
-    }
-
-
-    public void registerPaths(final Class<? extends BaseIdentity> context,
-        final Class<? extends RpcService> service, final Set<InstanceIdentifier<?>> set) {
-        QName ctx = BindingReflections.findQName(context);
-        for (YangInstanceIdentifier path : Collections2.transform(set, toDOMInstanceIdentifier)) {
-            for (RoutedRpcRegistration reg : registrations) {
-                reg.registerPath(ctx, path);
-            }
-        }
-    }
-
-    @Override
-    public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
-        if (EQUALS_METHOD.equals(method)) {
-            return false;
-        }
-        RpcInvocationStrategy strategy = strategiesByMethod.get(method);
-        checkState(strategy != null);
-        checkArgument(args.length <= 2);
-        if (args.length == 1) {
-            checkArgument(args[0] instanceof DataObject);
-            return strategy.forwardToDomBroker((DataObject) args[0]);
-        }
-        return strategy.forwardToDomBroker(null);
-    }
-
-    public void removePaths(final Class<? extends BaseIdentity> context, final Class<? extends RpcService> service,
-        final Set<InstanceIdentifier<?>> set) {
-        QName ctx = BindingReflections.findQName(context);
-        for (YangInstanceIdentifier path : Collections2.transform(set, toDOMInstanceIdentifier)) {
-            for (RoutedRpcRegistration reg : registrations) {
-                reg.unregisterPath(ctx, path);
-            }
-        }
-    }
-
-    @Override
-    public Set<QName> getSupportedRpcs() {
-        return supportedRpcs;
-    }
-
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    public void createDefaultDomForwarder() {
-        if (baRpcRegistryImpl != null) {
-            Class<?> cls = rpcServiceType.get();
-            ClassLoader clsLoader = cls.getClassLoader();
-            RpcService proxy = (RpcService) Proxy.newProxyInstance(clsLoader, new Class<?>[] { cls }, this);
-
-            RpcRouter rpcRouter = baRpcRegistryImpl.getRpcRouter(rpcServiceType.get());
-            rpcRouter.registerDefaultService(proxy);
-        }
-    }
-
-    @Override
-    public ListenableFuture<RpcResult<CompositeNode>> invokeRpc(final QName rpc, final CompositeNode domInput) {
-        checkArgument(rpc != null);
-        checkArgument(domInput != null);
-
-        Class<? extends RpcService> rpcType = rpcServiceType.get();
-        checkState(rpcType != null);
-        RpcService rpcService = baRpcRegistry.getRpcService(rpcType);
-        checkState(rpcService != null);
-        CompositeNode domUnwrappedInput = domInput.getFirstCompositeByName(QName.create(rpc, "input"));
-
-        try {
-            return Futures.immediateFuture(resolveInvocationStrategy(rpc).invokeOn(rpcService, domUnwrappedInput));
-        } catch (Exception e) {
-            return Futures.immediateFailedFuture(e);
-        }
-    }
-
-    private RpcInvocationStrategy resolveInvocationStrategy(final QName rpc) {
-        return strategiesByQName.get(rpc);
-    }
-
-    private RpcInvocationStrategy createInvocationStrategy(final QName rpc,
-        final Class<? extends RpcService> rpcType, final BindingIndependentMappingService mappingService) throws Exception {
-        return ClassLoaderUtils.withClassLoader(rpcType.getClassLoader(), new Callable<RpcInvocationStrategy>() {
-            @Override
-            public RpcInvocationStrategy call() throws Exception {
-                String methodName = BindingMapping.getMethodName(rpc);
-                Method targetMethod = null;
-                for (Method possibleMethod : rpcType.getMethods()) {
-                    if (possibleMethod.getName().equals(methodName)
-                        && BindingReflections.isRpcMethod(possibleMethod)) {
-                        targetMethod = possibleMethod;
-                        break;
-                    }
-                }
-                checkState(targetMethod != null, "Rpc method not found");
-                return new RpcInvocationStrategy(rpc, targetMethod, mappingService, biRpcRegistry);
-            }
-
-        });
-    }
-
-    /**
-     * Registers RPC Forwarder to Binding Broker,
-     * this means DOM Broekr has implementation of RPC
-     * which is registered to it.
-     *
-     * If RPC Forwarder was previously registered to DOM Broker
-     * or to Bidning Broker this method is noop to prevent
-     * creating forwarding loop.
-     *
-     */
-    public void registerToBindingBroker() {
-        if(!registrationInProgress && forwarderRegistration == null) {
-            try {
-                registrationInProgress = true;
-                this.forwarderRegistration = baRpcRegistry.addRpcImplementation((Class)rpcServiceType.get(), proxy);
-            } catch (Exception e) {
-                LOG.error("Unable to forward RPCs for {}",rpcServiceType.get(),e);
-            } finally {
-                registrationInProgress = false;
-            }
-        }
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingRpcForwardingManager.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingRpcForwardingManager.java
deleted file mode 100644 (file)
index b6bc488..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.connect.dom;
-
-import com.google.common.base.Optional;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.WeakHashMap;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChange;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
-import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
-import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
-
-/**
- * Manager responsible for instantiating forwarders responsible for
- * forwarding of RPC invocations from DOM Broker to Binding Aware Broker
- *
- */
-class DomToBindingRpcForwardingManager implements
-    RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>,
-    RpcProviderRegistryImpl.RouterInstantiationListener,
-    RpcProviderRegistryImpl.GlobalRpcRegistrationListener, RpcRegistrationListener {
-
-    private final Map<Class<? extends RpcService>, DomToBindingRpcForwarder> forwarders = new WeakHashMap<>();
-    private final BindingIndependentMappingService mappingService;
-    private final RpcProvisionRegistry biRpcRegistry;
-    private final RpcProviderRegistry baRpcRegistry;
-    private RpcProviderRegistryImpl registryImpl;
-
-    DomToBindingRpcForwardingManager(final BindingIndependentMappingService mappingService, final RpcProvisionRegistry biRpcRegistry,
-        final RpcProviderRegistry baRpcRegistry) {
-        this.mappingService = mappingService;
-        this.biRpcRegistry = biRpcRegistry;
-        this.baRpcRegistry = baRpcRegistry;
-    }
-
-    public RpcProviderRegistryImpl getRegistryImpl() {
-        return registryImpl;
-    }
-
-    public void setRegistryImpl(final RpcProviderRegistryImpl registryImpl) {
-        this.registryImpl = registryImpl;
-    }
-
-    @Override
-    public void onGlobalRpcRegistered(final Class<? extends RpcService> cls) {
-        getRpcForwarder(cls, null).registerToDOMBroker();
-    }
-
-    @Override
-    public void onGlobalRpcUnregistered(final Class<? extends RpcService> cls) {
-        // NOOP
-    }
-
-    @Override
-    public void onRpcRouterCreated(final RpcRouter<?> router) {
-        Class<? extends BaseIdentity> ctx = router.getContexts().iterator().next();
-        getRpcForwarder(router.getServiceType(), ctx);
-    }
-
-    @Override
-    public void onRouteChange(final RouteChange<RpcContextIdentifier, InstanceIdentifier<?>> change) {
-        // Process removals first
-        for (Entry<RpcContextIdentifier, Set<InstanceIdentifier<?>>> entry : change.getRemovals().entrySet()) {
-            final Class<? extends BaseIdentity> context = entry.getKey().getRoutingContext();
-            if (context != null) {
-                final Class<? extends RpcService> service = entry.getKey().getRpcService();
-                getRpcForwarder(service, context).removePaths(context, service, entry.getValue());
-            }
-        }
-
-        for (Entry<RpcContextIdentifier, Set<InstanceIdentifier<?>>> entry : change.getAnnouncements().entrySet()) {
-            final Class<? extends BaseIdentity> context = entry.getKey().getRoutingContext();
-            if (context != null) {
-                final Class<? extends RpcService> service = entry.getKey().getRpcService();
-                getRpcForwarder(service, context).registerPaths(context, service, entry.getValue());
-            }
-        }
-    }
-
-    private DomToBindingRpcForwarder getRpcForwarder(final Class<? extends RpcService> service,
-        final Class<? extends BaseIdentity> context) {
-        DomToBindingRpcForwarder potential = forwarders.get(service);
-        if (potential != null) {
-            return potential;
-        }
-        if (context == null) {
-            potential = new DomToBindingRpcForwarder(service, mappingService, biRpcRegistry, baRpcRegistry,registryImpl);
-        } else {
-            potential = new DomToBindingRpcForwarder(service, context, mappingService, biRpcRegistry, baRpcRegistry,registryImpl);
-        }
-
-        forwarders.put(service, potential);
-        return potential;
-    }
-
-    @Override
-    public void onRpcImplementationAdded(final QName name) {
-
-        final Optional<Class<? extends RpcService>> rpcInterface = mappingService.getRpcServiceClassFor(
-            name.getNamespace().toString(), name.getFormattedRevision());
-        if (rpcInterface.isPresent()) {
-            getRpcForwarder(rpcInterface.get(), null).registerToBindingBroker();
-        }
-    }
-
-    @Override
-    public void onRpcImplementationRemoved(final QName name) {
-
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingTransaction.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DomToBindingTransaction.java
deleted file mode 100644 (file)
index 82c15ef..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.connect.dom;
-
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
-@Deprecated
-class DomToBindingTransaction implements
-    DataCommitHandler.DataCommitTransaction<YangInstanceIdentifier, CompositeNode> {
-
-    private final org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction backing;
-    private final DataModification<YangInstanceIdentifier, CompositeNode> modification;
-    private final ConcurrentMap<Object, DomToBindingTransaction> bindingOpenedTransactions;
-
-    public DomToBindingTransaction(
-    final org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction backing,
-    final DataModification<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> modification,
-        ConcurrentMap<Object, DomToBindingTransaction> bindingOpenedTransactions) {
-        super();
-        this.backing = backing;
-        this.modification = modification;
-        this.bindingOpenedTransactions = bindingOpenedTransactions;
-        this.bindingOpenedTransactions.put(backing.getIdentifier(), this);
-    }
-
-    @Override
-    public DataModification<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> getModification() {
-        return modification;
-    }
-
-    @Override
-    public RpcResult<Void> rollback() throws IllegalStateException {
-        bindingOpenedTransactions.remove(backing.getIdentifier());
-        return RpcResultBuilder.<Void> success().build();
-    }
-
-    @Override
-    public RpcResult<Void> finish() throws IllegalStateException {
-        Future<RpcResult<TransactionStatus>> result = backing.commit();
-        try {
-            RpcResult<TransactionStatus> baResult = result.get();
-            bindingOpenedTransactions.remove(backing.getIdentifier());
-            return RpcResultBuilder.<Void> status(baResult.isSuccessful())
-                                          .withRpcErrors(baResult.getErrors()).build();
-        } catch (InterruptedException e) {
-            throw new IllegalStateException("", e);
-        } catch (ExecutionException e) {
-            throw new IllegalStateException("", e);
-        } finally {
-            bindingOpenedTransactions.remove(backing.getIdentifier());
-        }
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/RpcInvocationStrategy.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/RpcInvocationStrategy.java
deleted file mode 100644 (file)
index 2a6de4a..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- ** Copyright (c) 2014 Brocade Communications 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.sal.binding.impl.connect.dom;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.concurrent.Future;
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.Node;
-import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
-import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
-
-/*
- * RPC's can have both input, output, one or the other, or neither.
- *
- * This class handles the permutations and provides two means of invocation:
- * 1. forwardToDomBroker
- * 2.
- *
- * Weak References to the input and output classes are used to allow these classes to
- * be from another OSGi bundle/class loader which may come and go.
- *
- */
-public class RpcInvocationStrategy {
-    private final Function<RpcResult<CompositeNode>, RpcResult<?>> transformationFunction = new Function<RpcResult<CompositeNode>, RpcResult<?>>() {
-        @SuppressWarnings("rawtypes")
-        @Override
-        public RpcResult<?> apply(final RpcResult<CompositeNode> result) {
-            final Object output;
-            if (getOutputClass() != null && result.getResult() != null) {
-                output = mappingService.dataObjectFromDataDom(getOutputClass().get(), result.getResult());
-            } else {
-                output = null;
-            }
-
-            return RpcResultBuilder.from( (RpcResult)result ).withResult( output ).build();
-        }
-    };
-
-    private final BindingIndependentMappingService mappingService;
-    private final RpcProvisionRegistry biRpcRegistry;
-    protected final Method targetMethod;
-    protected final QName rpc;
-
-    @SuppressWarnings("rawtypes")
-    private final WeakReference<Class> inputClass;
-
-    @SuppressWarnings("rawtypes")
-    private final WeakReference<Class> outputClass;
-
-    @SuppressWarnings({ "rawtypes" })
-    public RpcInvocationStrategy(final QName rpc,
-                                 final Method targetMethod,
-                                 final BindingIndependentMappingService mappingService,
-                                 final RpcProvisionRegistry biRpcRegistry ) {
-        this.mappingService = mappingService;
-        this.biRpcRegistry = biRpcRegistry;
-        this.targetMethod = targetMethod;
-        this.rpc = rpc;
-
-        final Optional<Class<?>> outputClassOption = BindingReflections.resolveRpcOutputClass(targetMethod);
-        if (outputClassOption.isPresent()) {
-            this.outputClass = new WeakReference(outputClassOption.get());
-        } else {
-            this.outputClass = null;
-        }
-
-        final Optional<Class<? extends DataContainer>> inputClassOption = BindingReflections.resolveRpcInputClass(targetMethod);
-        if (inputClassOption.isPresent() ) {
-            this.inputClass = new WeakReference(inputClassOption.get());
-        } else {
-            this.inputClass = null;
-        }
-    }
-
-    @SuppressWarnings({ "unchecked" })
-    public ListenableFuture<RpcResult<?>> forwardToDomBroker(final DataObject input) {
-
-        if(biRpcRegistry == null) {
-            return Futures.<RpcResult<?>> immediateFuture(RpcResultBuilder.failed().build());
-        }
-
-        CompositeNode inputXml = null;
-        if( input != null ) {
-            CompositeNode xml = mappingService.toDataDom(input);
-            inputXml = ImmutableCompositeNode.create(rpc, ImmutableList.<Node<?>> of(xml));
-        } else {
-            inputXml = ImmutableCompositeNode.create( rpc, Collections.<Node<?>>emptyList() );
-        }
-
-        return Futures.transform(biRpcRegistry.invokeRpc(rpc, inputXml), transformationFunction);
-    }
-
-    @SuppressWarnings("unchecked")
-    private RpcResult<CompositeNode> uncheckedInvoke(final RpcService rpcService, final CompositeNode domInput) throws Exception {
-
-        Future<RpcResult<?>> futureResult = null;
-
-        if( inputClass != null ){
-            DataContainer bindingInput = mappingService.dataObjectFromDataDom(inputClass.get(), domInput);
-            futureResult = (Future<RpcResult<?>>) targetMethod.invoke(rpcService, bindingInput);
-
-        } else {
-            futureResult = (Future<RpcResult<?>>) targetMethod.invoke(rpcService);
-        }
-
-        if (futureResult == null) {
-            return RpcResultBuilder.<CompositeNode>failed().build();
-        }
-
-        @SuppressWarnings("rawtypes")
-        RpcResult bindingResult = futureResult.get();
-
-        final Object resultObj = bindingResult.getResult();
-        Object output = null;
-        if (resultObj instanceof DataObject) {
-            output = mappingService.toDataDom((DataObject)resultObj);
-        }
-        return RpcResultBuilder.from( bindingResult ).withResult( output ).build();
-    }
-
-    public RpcResult<CompositeNode> invokeOn(final RpcService rpcService, final CompositeNode domInput) throws Exception {
-        return uncheckedInvoke(rpcService, domInput);
-    }
-
-    @SuppressWarnings("rawtypes")
-    @VisibleForTesting
-    WeakReference<Class> getOutputClass() {
-        return outputClass;
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBindingBrokerImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBindingBrokerImpl.java
deleted file mode 100644 (file)
index 9283663..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * 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.sal.binding.impl.forward;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
-import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
-import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingDomConnectorDeployer;
-import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;
-import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class DomForwardedBindingBrokerImpl extends RootBindingAwareBroker implements DomForwardedBroker {
-
-    private ProviderSession domProviderContext;
-    private BindingIndependentConnector connector;
-
-    private MountProvisionService domMountService;
-
-    private final DomMountPointForwardingManager domForwardingManager = new DomMountPointForwardingManager();
-    private final BindingMountPointForwardingManager bindingForwardingManager = new BindingMountPointForwardingManager();
-
-    private ConcurrentMap<InstanceIdentifier<?>, BindingIndependentConnector> connectors = new ConcurrentHashMap<>();
-    private ConcurrentMap<InstanceIdentifier<?>, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier> forwarded = new ConcurrentHashMap<>();
-    private ListenerRegistration<MountProvisionListener> domListenerRegistration;
-    private ListenerRegistration<org.opendaylight.controller.sal.binding.api.mount.MountProviderService.MountProvisionListener> baListenerRegistration;
-
-
-    public DomForwardedBindingBrokerImpl(String instanceName) {
-        super(instanceName);
-    }
-
-    @Override
-    public BindingIndependentConnector getConnector() {
-        return connector;
-    }
-
-    @Override
-    public ProviderSession getDomProviderContext() {
-        return domProviderContext;
-    }
-
-    @Override
-    public void setConnector(BindingIndependentConnector connector) {
-        this.connector = connector;
-    }
-
-    @Override
-    public void setDomProviderContext(ProviderSession domProviderContext) {
-        this.domProviderContext = domProviderContext;
-    }
-
-    @Override
-    public void startForwarding() {
-        BindingDomConnectorDeployer.startDataForwarding(getConnector(), getDataBroker(), getDomProviderContext());
-        BindingDomConnectorDeployer.startRpcForwarding(getConnector(), getRpcProviderRegistry(),
-                getDomProviderContext());
-        BindingDomConnectorDeployer.startNotificationForwarding(getConnector(), getNotificationBroker(),
-                getDomProviderContext());
-        startMountpointForwarding();
-    }
-
-    private void startMountpointForwarding() {
-        domMountService = getDomProviderContext().getService(MountProvisionService.class);
-        if (domMountService != null && getMountManager() != null) {
-            domListenerRegistration = domMountService.registerProvisionListener(domForwardingManager);
-            baListenerRegistration = getMountManager().registerProvisionListener(bindingForwardingManager);
-        }
-    }
-
-    public MountProvisionService getDomMountService() {
-        return domMountService;
-    }
-
-    public void setDomMountService(MountProvisionService domMountService) {
-        this.domMountService = domMountService;
-    }
-
-    private void tryToDeployConnector(InstanceIdentifier<?> baPath,
-            org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biPath) {
-        org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier previous = forwarded.putIfAbsent(baPath, biPath);
-        if (previous != null) {
-            return;
-        }
-        MountProviderInstance baMountPoint = getMountManager().createOrGetMountPoint(baPath);
-        MountProvisionInstance domMountPoint = domMountService.createOrGetMountPoint(biPath);
-        BindingIndependentConnector connector = createForwarder(baPath, baMountPoint, domMountPoint);
-        connectors.put(baPath, connector);
-    }
-
-    private BindingIndependentConnector createForwarder(InstanceIdentifier<?> path, MountProviderInstance baMountPoint,
-            MountProvisionInstance domMountPoint) {
-        BindingIndependentConnector mountConnector = BindingDomConnectorDeployer.createConnector(getConnector());
-
-        BindingDomConnectorDeployer.startDataForwarding(mountConnector, baMountPoint, domMountPoint);
-        BindingDomConnectorDeployer.startRpcForwarding(mountConnector, baMountPoint, domMountPoint);
-        BindingDomConnectorDeployer.startNotificationForwarding(mountConnector, baMountPoint, domMountPoint);
-        // connector.setDomNotificationBroker(domMountPoint);
-        return mountConnector;
-    }
-
-    public synchronized void tryToDeployDomForwarder(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier domPath) {
-        InstanceIdentifier<?> baPath;
-        try {
-            baPath = connector.getMappingService().fromDataDom(domPath);
-            BindingIndependentConnector potentialConnector = connectors.get(baPath);
-            if (potentialConnector != null) {
-                return;
-            }
-            tryToDeployConnector(baPath, domPath);
-        } catch (DeserializationException e) {
-
-        }
-    }
-
-    public synchronized void tryToDeployBindingForwarder(InstanceIdentifier<?> baPath) {
-        BindingIndependentConnector potentialConnector = connectors.get(baPath);
-        if (potentialConnector != null) {
-            return;
-        }
-        org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier domPath = connector.getMappingService().toDataDom(baPath);
-        tryToDeployConnector(baPath, domPath);
-    }
-
-    public synchronized void undeployBindingForwarder(InstanceIdentifier<?> baPath) {
-        // FIXME: Implement closeMountPoint
-    }
-
-    public synchronized void undeployDomForwarder(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier biPath) {
-        // FIXME: Implement closeMountPoint
-    }
-
-    private class DomMountPointForwardingManager implements MountProvisionListener {
-
-        @Override
-        public void onMountPointCreated(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier path) {
-            tryToDeployDomForwarder(path);
-        }
-
-        @Override
-        public void onMountPointRemoved(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier path) {
-            undeployDomForwarder(path);
-        }
-    }
-
-    private class BindingMountPointForwardingManager implements
-            org.opendaylight.controller.sal.binding.api.mount.MountProviderService.MountProvisionListener {
-
-        @Override
-        public void onMountPointCreated(InstanceIdentifier<?> path) {
-            tryToDeployBindingForwarder(path);
-        }
-
-        @Override
-        public void onMountPointRemoved(InstanceIdentifier<?> path) {
-            undeployBindingForwarder(path);
-        }
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBroker.java
deleted file mode 100644 (file)
index db98b45..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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.sal.binding.impl.forward;
-
-import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
-
-public interface DomForwardedBroker {
-
-    public BindingIndependentConnector getConnector();
-
-    public void setConnector(BindingIndependentConnector connector);
-
-    public void setDomProviderContext(ProviderSession domProviderContext);
-
-    public ProviderSession getDomProviderContext();
-
-    void startForwarding();
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardingUtils.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardingUtils.java
deleted file mode 100644 (file)
index d28b3b5..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.sal.binding.impl.forward;
-
-import com.google.common.base.Preconditions;
-
-public class DomForwardingUtils {
-
-    public static boolean isDomForwardedBroker(Object obj) {
-        return obj instanceof DomForwardedBroker;
-    }
-
-    public static void reuseForwardingFrom(Object target,Object source) {
-        Preconditions.checkArgument(isDomForwardedBroker(source));
-        Preconditions.checkArgument(isDomForwardedBroker(target));
-        DomForwardedBroker forwardedSource = (DomForwardedBroker) source;
-        DomForwardedBroker forwardedTarget = (DomForwardedBroker) target;
-        reuseForwardingFrom(forwardedTarget, forwardedSource);
-
-    }
-
-    private static void reuseForwardingFrom(DomForwardedBroker target, DomForwardedBroker source) {
-        target.setConnector(source.getConnector());
-        target.setDomProviderContext(source.getDomProviderContext());
-    }
-
-}
index 8e28089..b62f596 100644 (file)
@@ -117,30 +117,33 @@ module opendaylight-sal-binding-broker-impl {
                     }
                 }
             }*/
-
-            container data-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity sal:binding-data-broker;
+            container binding-broker-impl {
+                uses dom-forwarding-component;
+    
+                container data-broker {
+                    uses config:service-ref {
+                        refine type {
+                            mandatory false;
+                            config:required-identity sal:binding-data-broker;
+                        }
                     }
                 }
-            }
-
-            container notification-service {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity sal:binding-notification-service;
+    
+                container notification-service {
+                    uses config:service-ref {
+                        refine type {
+                            mandatory true;
+                            config:required-identity sal:binding-notification-service;
+                        }
                     }
                 }
-            }
-
-            container root-data-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity sal:binding-async-data-broker;
+    
+                container root-data-broker {
+                    uses config:service-ref {
+                        refine type {
+                            mandatory false;
+                            config:required-identity sal:binding-async-data-broker;
+                        }
                     }
                 }
             }
@@ -151,7 +154,16 @@ module opendaylight-sal-binding-broker-impl {
         case binding-data-compatible-broker {
             when "/config:modules/config:module/config:type = 'binding-data-compatible-broker'";
 
-            uses dom-forwarding-component;
+            container binding-data-compatible-broker {
+                container data-broker {
+                    uses config:service-ref {
+                        refine type {
+                            mandatory false;
+                            config:required-identity sal:binding-async-data-broker;
+                        }
+                    }
+                }
+            }
         }
     }
 
index 6da1633..6a8dc5f 100644 (file)
@@ -10,6 +10,8 @@ package org.opendaylight.controller.md.sal.binding.impl.test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter;
+
 import com.google.common.collect.ImmutableList;
 import java.util.ArrayList;
 import java.util.List;
@@ -18,7 +20,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.binding.impl.compat.HeliumNotificationProviderServiceAdapter;
 import org.opendaylight.controller.md.sal.binding.test.AbstractNotificationBrokerTest;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.OpendaylightMdsalListTestListener;
index 2ec1c43..31edc4a 100644 (file)
@@ -1,9 +1,14 @@
 package org.opendaylight.controller.md.sal.binding.impl.test;
 
-import com.google.common.util.concurrent.MoreExecutors;
+import static junit.framework.TestCase.assertNotNull;
+
+import org.opendaylight.controller.md.sal.binding.compat.HydrogenDataBrokerAdapter;
+
+import com.google.common.collect.ImmutableSet;
+import java.util.concurrent.ExecutionException;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.impl.ForwardedBackwardsCompatibleDataBroker;
-import org.opendaylight.controller.md.sal.binding.test.AbstractSchemaAwareTest;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
 import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestCustomizer;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
@@ -13,17 +18,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-import java.util.concurrent.ExecutionException;
-
-import static junit.framework.TestCase.assertNotNull;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
 
+@Deprecated
 public class ForwardedBackwardsCompatibleDataBrokerTest extends
-    AbstractSchemaAwareTest {
+    AbstractDataBrokerTest {
 
     private DataBrokerTestCustomizer testCustomizer;
-    private ForwardedBackwardsCompatibleDataBroker dataBroker;
+    private HydrogenDataBrokerAdapter dataBroker;
     private DOMDataBroker domBroker;
 
     private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
@@ -31,22 +34,20 @@ public class ForwardedBackwardsCompatibleDataBrokerTest extends
     private static final InstanceIdentifier<TopLevelList> NODE_PATH = TOP_PATH.child(TopLevelList.class, TOP_LIST_KEY);
     private static final TopLevelList NODE = new TopLevelListBuilder().setKey(TOP_LIST_KEY).build();
 
-    protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
-        return new DataBrokerTestCustomizer();
+    @Override
+    protected Iterable<YangModuleInfo> getModuleInfos() throws Exception {
+        return ImmutableSet.of(BindingReflections.getModuleInfo(TopLevelList.class));
     }
 
     @Override
-    protected void setupWithSchema(final SchemaContext context) {
-        testCustomizer = createDataBrokerTestCustomizer();
-
-        domBroker = testCustomizer.createDOMDataBroker();
-        dataBroker = createBackwardsCompatibleDataBroker();
-        testCustomizer.updateSchema(context);
+    protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
+        return new DataBrokerTestCustomizer();
     }
 
-    public ForwardedBackwardsCompatibleDataBroker createBackwardsCompatibleDataBroker() {
-        return new ForwardedBackwardsCompatibleDataBroker(domBroker, testCustomizer.getBindingToNormalized(), testCustomizer.getSchemaService(), MoreExecutors
-            .sameThreadExecutor());
+    @Override
+    protected void setupWithDataBroker(final DataBroker dataBroker) {
+        super.setupWithDataBroker(dataBroker);
+        this.dataBroker = new HydrogenDataBrokerAdapter(dataBroker);
     }
 
 
@@ -62,15 +63,15 @@ public class ForwardedBackwardsCompatibleDataBrokerTest extends
      */
     @Test
     public void testEnsureParentsByMerge() throws InterruptedException, ExecutionException {
-        DataModificationTransaction writeTx =
+        final DataModificationTransaction writeTx =
             dataBroker.beginTransaction();
 
         writeTx.putOperationalData(NODE_PATH, NODE);
 
-        writeTx.commit();
+        writeTx.commit().get();
 
         // TOP_PATH should exist as it is the parent of NODE_PATH
-        DataObject object = dataBroker.readOperationalData(TOP_PATH);
+        final DataObject object = dataBroker.readOperationalData(TOP_PATH);
 
         assertNotNull(object);
 
index 8782046..4535a7f 100644 (file)
 package org.opendaylight.controller.md.sal.binding.impl.test;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
 import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_BAR_KEY;
 import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY;
 import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path;
 
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
+import org.opendaylight.controller.md.sal.binding.compat.HeliumRpcProviderRegistry;
 
-import org.junit.Before;
+import com.google.common.base.Throwables;
+import java.util.Arrays;
+import javassist.ClassPool;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.opendaylight.controller.md.sal.binding.test.AssertCollections;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChange;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcServiceAdapter;
+import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
+import org.opendaylight.controller.md.sal.binding.test.AbstractSchemaAwareTest;
+import org.opendaylight.controller.md.sal.dom.broker.impl.DOMRpcRouter;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
 import org.opendaylight.controller.sal.binding.codegen.RpcIsNotRoutedException;
-import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.OpendaylightTestRoutedRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.TestContext;
+import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator;
+import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
+import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-import com.google.common.util.concurrent.SettableFuture;
 
-
-public class RpcProviderRegistryTest {
+public class RpcProviderRegistryTest  extends AbstractSchemaAwareTest {
 
     private static InstanceIdentifier<TopLevelList> FOO_PATH = path(TOP_FOO_KEY);
     private static InstanceIdentifier<TopLevelList> BAR_PATH = path(TOP_BAR_KEY);
     private static RpcContextIdentifier ROUTING_CONTEXT = RpcContextIdentifier.contextFor(OpendaylightTestRoutedRpcService.class, TestContext.class);
 
-    private RpcProviderRegistryImpl rpcRegistry;
-
-    @Before
-    public void setup() {
-        rpcRegistry = new RpcProviderRegistryImpl("test");
-    }
+    private RpcProviderRegistry rpcRegistry;
 
-    private static class TestListener implements RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>> {
 
-        final SettableFuture<RouteChange<RpcContextIdentifier, InstanceIdentifier<?>>> event = SettableFuture.create();
-        @Override
-        public void onRouteChange(
-                final RouteChange<RpcContextIdentifier, InstanceIdentifier<?>> change) {
-            event.set(change);
+    @Override
+    protected Iterable<YangModuleInfo> getModuleInfos() {
+        try {
+            return Arrays.asList(
+                    BindingReflections.getModuleInfo(TopLevelList.class),
+                    BindingReflections.getModuleInfo(OpendaylightTestRoutedRpcService.class),
+                    BindingReflections.getModuleInfo(OpendaylightTestRpcServiceService.class));
+        } catch (final Exception e) {
+            throw Throwables.propagate(e);
         }
     }
 
+    @Override
+    protected void setupWithSchema(final SchemaContext context) {
+        final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()));
+        final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(generator);
+        final GeneratedClassLoadingStrategy classLoadingStrategy = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
+        final BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(classLoadingStrategy, null, codecRegistry);
+        final DOMRpcRouter domRpcRegistry = new DOMRpcRouter();
+        domRpcRegistry.onGlobalContextUpdated(context);
+        codec.onGlobalContextUpdated(context);
+        final RpcConsumerRegistry consumer = new BindingDOMRpcServiceAdapter(domRpcRegistry, codec);
+        final BindingDOMRpcProviderServiceAdapter provider = new BindingDOMRpcProviderServiceAdapter( domRpcRegistry,codec);
+        rpcRegistry = new HeliumRpcProviderRegistry(consumer,provider);
+    }
+
     @Test
     public void testGlobalRpcRegistrations() throws Exception {
-        OpendaylightTestRpcServiceService one = Mockito.mock(OpendaylightTestRpcServiceService.class);
-        OpendaylightTestRpcServiceService two = Mockito.mock(OpendaylightTestRpcServiceService.class);
+        final OpendaylightTestRpcServiceService one = Mockito.mock(OpendaylightTestRpcServiceService.class);
+        final OpendaylightTestRpcServiceService two = Mockito.mock(OpendaylightTestRpcServiceService.class);
 
-        RpcRegistration<OpendaylightTestRpcServiceService> regOne = rpcRegistry.addRpcImplementation(OpendaylightTestRpcServiceService.class, one);
+        final RpcRegistration<OpendaylightTestRpcServiceService> regOne = rpcRegistry.addRpcImplementation(OpendaylightTestRpcServiceService.class, one);
         assertNotNull(regOne);
-
-        try {
-            rpcRegistry.addRpcImplementation(OpendaylightTestRpcServiceService.class, two);
-        fail("Second call for registration of same RPC must throw IllegalStateException");
-        } catch (IllegalStateException e) {
-            assertNotNull(e.getMessage());
-        }
-
+        rpcRegistry.addRpcImplementation(OpendaylightTestRpcServiceService.class, two);
         regOne.close();
-
-        RpcRegistration<OpendaylightTestRpcServiceService> regTwo = rpcRegistry.addRpcImplementation(OpendaylightTestRpcServiceService.class, two);
+        final RpcRegistration<OpendaylightTestRpcServiceService> regTwo = rpcRegistry.addRpcImplementation(OpendaylightTestRpcServiceService.class, two);
         assertNotNull(regTwo);
     }
 
-    @Test
-    public void routedRpcRegisteredUsingGlobalAsDefaultInstance() throws Exception {
-        OpendaylightTestRoutedRpcService def = Mockito.mock(OpendaylightTestRoutedRpcService.class);
-        rpcRegistry.addRpcImplementation(OpendaylightTestRoutedRpcService.class, def);
-        RpcRouter<OpendaylightTestRoutedRpcService> router = rpcRegistry.getRpcRouter(OpendaylightTestRoutedRpcService.class);
-        assertEquals(def, router.getDefaultService());
-    }
 
     @Test
+    @Ignore
     public void nonRoutedRegisteredAsRouted() {
-        OpendaylightTestRpcServiceService one = Mockito.mock(OpendaylightTestRpcServiceService.class);
+        final OpendaylightTestRpcServiceService one = Mockito.mock(OpendaylightTestRpcServiceService.class);
         try {
-            rpcRegistry.addRoutedRpcImplementation(OpendaylightTestRpcServiceService.class, one);
+            final RoutedRpcRegistration<OpendaylightTestRpcServiceService> reg = rpcRegistry.addRoutedRpcImplementation(OpendaylightTestRpcServiceService.class, one);
+            reg.registerPath(null, BAR_PATH);
             fail("RpcIsNotRoutedException should be thrown");
-        } catch (RpcIsNotRoutedException e) {
+        } catch (final RpcIsNotRoutedException e) {
             assertNotNull(e.getMessage());
-        } catch (Exception e) {
+        } catch (final Exception e) {
             fail("RpcIsNotRoutedException should be thrown");
         }
 
     }
 
-    @Test
-    public void testRpcRouterInstance() throws Exception  {
-        OpendaylightTestRoutedRpcService def = Mockito.mock(OpendaylightTestRoutedRpcService.class);
-
-        RpcRouter<OpendaylightTestRoutedRpcService> router = rpcRegistry.getRpcRouter(OpendaylightTestRoutedRpcService.class);
-
-        assertEquals(OpendaylightTestRoutedRpcService.class, router.getServiceType());
-        assertNotNull(router.getInvocationProxy());
-        assertNull(router.getDefaultService());
-
-        AssertCollections.assertContains(router.getContexts(), TestContext.class);
-
-        RpcRegistration<OpendaylightTestRoutedRpcService> regDef = router.registerDefaultService(def);
-        assertNotNull(regDef);
-        assertEquals(OpendaylightTestRoutedRpcService.class,regDef.getServiceType());
-        assertEquals(def,regDef.getInstance());
-        assertEquals(def, router.getDefaultService());
-
-        regDef.close();
-        assertNull("Default instance should be null after closing registration",  router.getDefaultService());
-    }
-
-    @Test
-    public void testRoutedRpcPathChangeEvents() throws InterruptedException, TimeoutException, ExecutionException {
-        OpendaylightTestRoutedRpcService one = Mockito.mock(OpendaylightTestRoutedRpcService.class);
-        OpendaylightTestRoutedRpcService two = Mockito.mock(OpendaylightTestRoutedRpcService.class);
-        RoutedRpcRegistration<OpendaylightTestRoutedRpcService> regOne = rpcRegistry.addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, one);
-        RoutedRpcRegistration<OpendaylightTestRoutedRpcService> regTwo = rpcRegistry.addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, two);
-        assertNotNull(regOne);
-        assertNotNull(regTwo);
-
-        final TestListener addListener = new TestListener();
-        rpcRegistry.registerRouteChangeListener(addListener);
-        regOne.registerPath(TestContext.class, FOO_PATH);
-
-        RouteChange<RpcContextIdentifier, InstanceIdentifier<?>> fooAddEvent = addListener.event.get(500, TimeUnit.MILLISECONDS);
-        Set<InstanceIdentifier<?>> announce = fooAddEvent.getAnnouncements().get(ROUTING_CONTEXT);
-        assertNotNull(announce);
-        AssertCollections.assertContains(announce, FOO_PATH);
-        AssertCollections.assertNotContains(announce, BAR_PATH);
-
-
-
-        final TestListener removeListener = new TestListener();
-        rpcRegistry.registerRouteChangeListener(removeListener);
-
-        regOne.unregisterPath(TestContext.class, FOO_PATH);
-
-        RouteChange<RpcContextIdentifier, InstanceIdentifier<?>> fooRemoveEvent = removeListener.event.get(500, TimeUnit.MILLISECONDS);
-        Set<InstanceIdentifier<?>> removal = fooRemoveEvent.getRemovals().get(ROUTING_CONTEXT);
-        assertNotNull(removal);
-        AssertCollections.assertContains(removal, FOO_PATH);
-        AssertCollections.assertNotContains(removal, BAR_PATH);
-
-
-    }
-
 }
index bf0cd6b..f8f45f2 100644 (file)
@@ -38,7 +38,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 public class DataBrokerTestCustomizer {
 
     private DOMDataBroker domDataBroker;
-    private DOMNotificationRouter domNotificationRouter;
+    private final DOMNotificationRouter domNotificationRouter;
     private final RuntimeGeneratedMappingServiceImpl mappingService;
     private final MockSchemaService schemaService;
     private ImmutableMap<LogicalDatastoreType, DOMStore> datastores;
@@ -53,24 +53,24 @@ public class DataBrokerTestCustomizer {
 
     public DataBrokerTestCustomizer() {
         schemaService = new MockSchemaService();
-        ClassPool pool = ClassPool.getDefault();
+        final ClassPool pool = ClassPool.getDefault();
         mappingService = new RuntimeGeneratedMappingServiceImpl(pool);
-        DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(pool));
-        BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(generator);
-        GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
+        final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(pool));
+        final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(generator);
+        final GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
         bindingToNormalized = new BindingToNormalizedNodeCodec(loading, mappingService, codecRegistry);
         schemaService.registerSchemaContextListener(bindingToNormalized);
         domNotificationRouter = DOMNotificationRouter.create(16);
     }
 
     public DOMStore createConfigurationDatastore() {
-        InMemoryDOMDataStore store = new InMemoryDOMDataStore("CFG", MoreExecutors.sameThreadExecutor());
+        final InMemoryDOMDataStore store = new InMemoryDOMDataStore("CFG", MoreExecutors.sameThreadExecutor());
         schemaService.registerSchemaContextListener(store);
         return store;
     }
 
     public DOMStore createOperationalDatastore() {
-        InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor());
+        final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor());
         schemaService.registerSchemaContextListener(store);
         return store;
     }
@@ -94,7 +94,7 @@ public class DataBrokerTestCustomizer {
     }
 
     public DataBroker createDataBroker() {
-        return new ForwardedBindingDataBroker(getDOMDataBroker(), bindingToNormalized, schemaService );
+        return new ForwardedBindingDataBroker(getDOMDataBroker(), bindingToNormalized);
     }
 
     public BindingToNormalizedNodeCodec getBindingToNormalized() {
diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/impl/connect/dom/RpcInvocationStrategyTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/impl/connect/dom/RpcInvocationStrategyTest.java
deleted file mode 100644 (file)
index 116491b..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
-* Copyright (c) 2014 Brocade Communications 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.sal.binding.impl.connect.dom;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
-
-public class RpcInvocationStrategyTest {
-
-    @Mock
-    private BindingIndependentMappingService mockMappingService;
-    @Mock
-    private RpcProvisionRegistry mockbiRpcRegistry;
-
-    private RpcInvocationStrategy rpcInvocationStrategy;
-    private ListenableFuture<RpcResult<DataObject>> futureDataObj;
-    private ListenableFuture<RpcResult<CompositeNode>> futureCompNode;
-    private final RpcError rpcError = mock(RpcError.class);
-    private final Collection<RpcError> errors = new ArrayList<RpcError>();
-
-    private final CompositeNode inputInvokeOn = mock(CompositeNode.class);
-    private final CompositeNode outputInvokeOn = mock(CompositeNode.class);
-
-    private final DataObject toDataDomInput = mock(DataObject.class);
-    private final CompositeNode toDataDomReturn = mock(CompositeNode.class);
-    private final CompositeNode invokeRpcResult = mock(CompositeNode.class);
-
-    private final DataObject inputForward = mock(DataObject.class);
-    private final DataObject outputForward = mock(DataObject.class);
-
-    private QName mockQName;
-    private URI urn;
-
-    private final MockRpcService mockRpcService = new MockRpcService();
-
-    public class MockRpcService implements RpcService {
-
-        public Future<?> rpcnameWithInputNoOutput(final DataObject input) {
-            return futureDataObj;
-        }
-
-        public Future<RpcResult<DataObject>> rpcnameWithInputWithOutput(final DataObject input) {
-            return futureDataObj;
-        }
-
-        public Future<RpcResult<DataObject>> rpcnameNoInputWithOutput() {
-            return futureDataObj;
-        }
-
-        public Future<?> rpcnameNoInputNoOutput() {
-            return futureDataObj;
-        }
-    }
-
-    public RpcInvocationStrategyTest() {
-        MockitoAnnotations.initMocks(this);
-    }
-
-    @Before
-    public void testInit() throws Exception {
-        urn = new URI(new String("urn:a:valid:urn"));
-    }
-
-    private void setupForForwardToDom(final boolean hasOutput, final boolean hasInput, final int expectedErrorSize) {
-
-        if (expectedErrorSize > 0) {
-            errors.add(rpcError);
-        }
-        RpcResult<CompositeNode> result = RpcResultBuilder.<CompositeNode>success(invokeRpcResult)
-                                                            .withRpcErrors( errors ).build();
-        futureCompNode = Futures.immediateFuture(result);
-        if( hasInput )
-        {
-            when(mockMappingService.toDataDom(inputForward)).thenReturn(toDataDomReturn);
-        }
-        when(mockbiRpcRegistry.invokeRpc(eq(mockQName), any(CompositeNode.class))).thenReturn(
-                futureCompNode);
-        if (hasOutput) {
-            when(
-                    mockMappingService.dataObjectFromDataDom(eq(rpcInvocationStrategy
-                            .getOutputClass().get()), any(CompositeNode.class))).thenReturn(
-                    outputForward);
-        }
-
-    }
-
-    private void validateForwardToDomBroker(final ListenableFuture<RpcResult<?>> forwardToDomBroker,
-            final boolean expectedSuccess, final DataObject expectedResult, final int expectedErrorSize)
-            throws InterruptedException, ExecutionException {
-        assertNotNull(forwardToDomBroker);
-        assertEquals(expectedSuccess, forwardToDomBroker.get().isSuccessful());
-        assertEquals(expectedResult, forwardToDomBroker.get().getResult());
-        assertEquals(expectedErrorSize, forwardToDomBroker.get().getErrors().size());
-    }
-
-    private void setupTestMethod(final String rpcName, final String testMethodName, final boolean hasInput)
-            throws NoSuchMethodException {
-        mockQName = QName.create(urn, new Date(0L), new String(rpcName));
-        java.lang.reflect.Method rpcMethod = hasInput ? MockRpcService.class.getMethod(rpcName,
-                DataObject.class) : MockRpcService.class.getMethod(rpcName);
-        rpcInvocationStrategy = new RpcInvocationStrategy(mockQName, rpcMethod, mockMappingService,
-                mockbiRpcRegistry);
-    }
-
-    /*
-     * forwardToDomBroker tests
-     */
-    @Test
-    public void testForwardToDomBroker_WithInputNoOutput() throws Exception {
-        setupTestMethod("rpcnameWithInputNoOutput", "testForwardToDomBroker_WithInputNoOutput",
-                true);
-        setupForForwardToDom(false, true, 0);
-        ListenableFuture<RpcResult<?>> forwardToDomBroker = rpcInvocationStrategy
-                .forwardToDomBroker(inputForward);
-
-        validateForwardToDomBroker(forwardToDomBroker, true, null, 0);
-    }
-
-    @Test
-    public void testForwardToDomBroker_WithInputNoOutput_error() throws Exception {
-        setupTestMethod("rpcnameWithInputNoOutput",
-                "testForwardToDomBroker_WithInputNoOutput_error", true);
-        setupForForwardToDom(false, true, 1);
-        ListenableFuture<RpcResult<?>> forwardToDomBroker = rpcInvocationStrategy
-                .forwardToDomBroker(inputForward);
-
-        validateForwardToDomBroker(forwardToDomBroker, true, null, 1);
-    }
-
-    @Test
-    public void testForwardToDomBroker_WithInputWithOutput() throws Exception {
-        setupTestMethod("rpcnameWithInputWithOutput", "testForwardToDomBroker_WithInputWithOutput",
-                true);
-        setupForForwardToDom(true, true, 0);
-        ListenableFuture<RpcResult<?>> forwardToDomBroker = rpcInvocationStrategy
-                .forwardToDomBroker(inputForward);
-        validateForwardToDomBroker(forwardToDomBroker, true, outputForward, 0);
-    }
-
-    @Test
-    public void testForwardToDomBroker_NoInputWithOutput() throws Exception {
-        setupTestMethod("rpcnameNoInputWithOutput", "testForwardToDomBroker_NoInputWithOutput",
-                false);
-        setupForForwardToDom(true, false, 0);
-        ListenableFuture<RpcResult<?>> forwardToDomBroker = rpcInvocationStrategy
-                .forwardToDomBroker(null);
-        validateForwardToDomBroker(forwardToDomBroker, true, outputForward, 0);
-    }
-
-    @Test
-    public void testForwardToDomBroker_NoInputNoOutput() throws Exception {
-        setupTestMethod("rpcnameNoInputNoOutput", "testForwardToDomBroker_NoInputNoOutput", false);
-        setupForForwardToDom(false, false, 0);
-        ListenableFuture<RpcResult<?>> forwardToDomBroker = rpcInvocationStrategy
-                .forwardToDomBroker(null);
-        validateForwardToDomBroker(forwardToDomBroker, true, null, 0);
-    }
-
-    /*
-     * invokeOn Tests
-     */
-    private void setupRpcResultsWithOutput(final int expectedErrorSize) {
-        if (expectedErrorSize > 0) {
-            errors.add(rpcError);
-        }
-        RpcResult<CompositeNode> resultCompNode = RpcResultBuilder.<CompositeNode>success(inputInvokeOn)
-                                                                        .withRpcErrors(errors).build();
-        futureCompNode = Futures.immediateFuture(resultCompNode);
-        RpcResult<DataObject> resultDataObj = RpcResultBuilder.<DataObject>success(toDataDomInput)
-                                                                           .withRpcErrors(errors).build();
-        futureDataObj = Futures.immediateFuture(resultDataObj);
-
-        when(mockMappingService.toDataDom(toDataDomInput)).thenReturn(outputInvokeOn);
-    }
-
-    private void setupRpcResultsNoOutput(final int expectedErrorSize) {
-        if (expectedErrorSize > 0) {
-            errors.add(rpcError);
-        }
-        RpcResult<CompositeNode> resultCompNode = RpcResultBuilder.<CompositeNode>success(inputInvokeOn)
-                                                                          .withRpcErrors(errors).build();
-        futureCompNode = Futures.immediateFuture(resultCompNode);
-        RpcResult<DataObject> resultDataObj = RpcResultBuilder.<DataObject>success()
-                                                                          .withRpcErrors(errors).build();
-        futureDataObj = Futures.immediateFuture(resultDataObj);
-    }
-
-    private void validateReturnedImmediateFuture(
-            final ListenableFuture<RpcResult<CompositeNode>> immediateFuture, final boolean expectedSuccess,
-            final CompositeNode expectedReturn, final int expectedErrorSize) throws InterruptedException,
-            ExecutionException {
-        assertNotNull(immediateFuture);
-        assertEquals(expectedSuccess, immediateFuture.get().isSuccessful());
-        assertEquals(expectedReturn, immediateFuture.get().getResult());
-        assertEquals(expectedErrorSize, immediateFuture.get().getErrors().size());
-    }
-
-    @Test
-    public void testInvokeOn_NoInputNoOutput() throws Exception {
-        setupTestMethod("rpcnameNoInputNoOutput", "testInvokeOn_NoInputNoOutput", false);
-        setupRpcResultsNoOutput(0);
-        ListenableFuture<RpcResult<CompositeNode>> immediateFuture = Futures
-                .immediateFuture(rpcInvocationStrategy.invokeOn(mockRpcService, inputInvokeOn));
-        validateReturnedImmediateFuture(immediateFuture, true, null, 0);
-    }
-
-    @Test
-    public void testInvokeOn_NoInputNoOutput_errors() throws Exception {
-        setupTestMethod("rpcnameNoInputNoOutput", "testInvokeOn_NoInputNoOutput", false);
-        setupRpcResultsNoOutput(1);
-        ListenableFuture<RpcResult<CompositeNode>> immediateFuture = Futures
-                .immediateFuture(rpcInvocationStrategy.invokeOn(mockRpcService, inputInvokeOn));
-        validateReturnedImmediateFuture(immediateFuture, true, null, 1);
-    }
-
-    @Test
-    public void testInvokeOn_WithInputNoOutput() throws Exception {
-        setupTestMethod("rpcnameWithInputNoOutput", "testInvokeOn_WithInputNoOutput", true);
-        setupRpcResultsNoOutput(0);
-        ListenableFuture<RpcResult<CompositeNode>> immediateFuture = Futures
-                .immediateFuture(rpcInvocationStrategy.invokeOn(mockRpcService, inputInvokeOn));
-        validateReturnedImmediateFuture(immediateFuture, true, null, 0);
-    }
-
-    @Test
-    public void testInvokeOn_WithInputWithOutput() throws Exception {
-        setupTestMethod("rpcnameWithInputWithOutput", "testInvokeOn_WithInputWithOutput", true);
-        setupRpcResultsWithOutput(0);
-        ListenableFuture<RpcResult<CompositeNode>> immediateFuture = Futures
-                .immediateFuture(rpcInvocationStrategy.invokeOn(mockRpcService, inputInvokeOn));
-        validateReturnedImmediateFuture(immediateFuture, true, outputInvokeOn, 0);
-    }
-
-    @Test
-    public void testInvokeOn_NoInputWithOutput() throws Exception {
-        setupTestMethod("rpcnameNoInputWithOutput", "testInvokeOn_NoInputWithOutput", false);
-        setupRpcResultsWithOutput(0);
-        ListenableFuture<RpcResult<CompositeNode>> immediateFuture = Futures
-                .immediateFuture(rpcInvocationStrategy.invokeOn(mockRpcService, inputInvokeOn));
-        validateReturnedImmediateFuture(immediateFuture, true, outputInvokeOn, 0);
-    }
-}
index 6ad93aa..58d6a3d 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.sal.binding.test.util;
 
 import static com.google.common.base.Preconditions.checkState;
+
 import com.google.common.annotations.Beta;
 import com.google.common.collect.ClassToInstanceMap;
 import com.google.common.collect.ImmutableClassToInstanceMap;
@@ -20,23 +21,31 @@ import java.util.Set;
 import java.util.concurrent.Future;
 import javassist.ClassPool;
 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.compat.HeliumRpcProviderRegistry;
+import org.opendaylight.controller.md.sal.binding.compat.HydrogenDataBrokerAdapter;
+import org.opendaylight.controller.md.sal.binding.compat.HydrogenMountProvisionServiceAdapter;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMMountPointServiceAdapter;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
+import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcServiceAdapter;
 import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.md.sal.binding.impl.ForwardedBackwardsCompatibleDataBroker;
 import org.opendaylight.controller.md.sal.binding.impl.ForwardedBindingDataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.controller.md.sal.dom.broker.impl.DOMRpcRouter;
 import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.broker.impl.compat.BackwardsCompatibleDataBroker;
+import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl;
 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
 import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
-import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;
 import org.opendaylight.controller.sal.binding.impl.NotificationBrokerImpl;
-import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;
-import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingDomConnectorDeployer;
-import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;
-import org.opendaylight.controller.sal.binding.impl.forward.DomForwardedBindingBrokerImpl;
+import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
 import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration;
@@ -44,10 +53,8 @@ import org.opendaylight.controller.sal.core.api.BrokerService;
 import org.opendaylight.controller.sal.core.api.RpcImplementation;
 import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
 import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
 import org.opendaylight.controller.sal.core.spi.data.DOMStore;
 import org.opendaylight.controller.sal.dom.broker.BrokerImpl;
-import org.opendaylight.controller.sal.dom.broker.MountPointManagerImpl;
 import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker;
 import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator;
 import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
@@ -64,27 +71,20 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 @Beta
 public class BindingTestContext implements AutoCloseable {
 
-    public static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier TREE_ROOT = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier
-            .builder().toInstance();
-
-    private static final Logger LOG = LoggerFactory.getLogger(BindingTestContext.class);
 
     private RuntimeGeneratedMappingServiceImpl mappingServiceImpl;
     private BindingToNormalizedNodeCodec codec;
 
-    private DomForwardedBindingBrokerImpl baBrokerImpl;
-    private DataBrokerImpl baDataImpl;
+    private RootBindingAwareBroker baBrokerImpl;
+
     private NotificationBrokerImpl baNotifyImpl;
-    private BindingIndependentConnector baConnectImpl;
 
-    private org.opendaylight.controller.sal.dom.broker.DataBrokerImpl biDataImpl;
-    @SuppressWarnings("deprecation")
+
+    @Deprecated
     private org.opendaylight.controller.sal.core.api.data.DataProviderService biDataLegacyBroker;
     private BrokerImpl biBrokerImpl;
 
@@ -93,15 +93,14 @@ public class BindingTestContext implements AutoCloseable {
 
     private final boolean startWithSchema;
 
-    private MountPointManagerImpl biMountImpl;
-
-
+    private DOMMountPointService biMountImpl;
 
     private ImmutableMap<LogicalDatastoreType, DOMStore> newDatastores;
 
+    @Deprecated
     private BackwardsCompatibleDataBroker biCompatibleBroker;
 
-    @SuppressWarnings("deprecation")
+    @Deprecated
     private DataProviderService baData;
 
     private DOMDataBroker newDOMDataBroker;
@@ -110,12 +109,21 @@ public class BindingTestContext implements AutoCloseable {
 
     private DataBroker dataBroker;
 
+    private RpcConsumerRegistry baConsumerRpc;
+
+    private BindingDOMRpcProviderServiceAdapter baProviderRpc;
+    private DOMRpcRouter domRouter;
+
 
 
     public DOMDataBroker getDomAsyncDataBroker() {
         return newDOMDataBroker;
     }
 
+    public BindingToNormalizedNodeCodec getCodec() {
+        return codec;
+    }
+
     protected BindingTestContext(final ListeningExecutorService executor, final ClassPool classPool, final boolean startWithSchema) {
         this.executor = executor;
         this.classPool = classPool;
@@ -123,22 +131,18 @@ public class BindingTestContext implements AutoCloseable {
     }
 
     public void startDomDataBroker() {
-        checkState(executor != null, "Executor needs to be set");
-        biDataImpl = new org.opendaylight.controller.sal.dom.broker.DataBrokerImpl();
-        biDataImpl.setExecutor(executor);
-        biDataLegacyBroker = biDataImpl;
     }
 
     public void startNewDataBroker() {
         checkState(executor != null, "Executor needs to be set");
         checkState(newDOMDataBroker != null, "DOM Data Broker must be set");
-        dataBroker = new ForwardedBindingDataBroker(newDOMDataBroker, codec, mockSchemaService);
+        dataBroker = new ForwardedBindingDataBroker(newDOMDataBroker, codec);
     }
 
     public void startNewDomDataBroker() {
         checkState(executor != null, "Executor needs to be set");
-        InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor());
-        InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.sameThreadExecutor());
+        final InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor());
+        final InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.sameThreadExecutor());
         newDatastores = ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
                 .put(LogicalDatastoreType.OPERATIONAL, operStore)
                 .put(LogicalDatastoreType.CONFIGURATION, configStore)
@@ -154,36 +158,30 @@ public class BindingTestContext implements AutoCloseable {
     }
 
     public void startBindingDataBroker() {
-        checkState(executor != null, "Executor needs to be set");
-        baDataImpl = new DataBrokerImpl();
-        baDataImpl.setExecutor(executor);
-        baData = baDataImpl;
+
     }
 
     public void startBindingBroker() {
         checkState(executor != null, "Executor needs to be set");
         checkState(baData != null, "Binding Data Broker must be started");
         checkState(baNotifyImpl != null, "Notification Service must be started");
-        baBrokerImpl = new DomForwardedBindingBrokerImpl("test");
 
-        baBrokerImpl.getMountManager().setDataCommitExecutor(executor);
-        baBrokerImpl.getMountManager().setNotificationExecutor(executor);
-        baBrokerImpl.setRpcBroker(new RpcProviderRegistryImpl("test"));
+        baConsumerRpc = new BindingDOMRpcServiceAdapter(getDomRpcInvoker(), codec);
+        baProviderRpc = new BindingDOMRpcProviderServiceAdapter(getDomRpcRegistry(), codec);
+
+        baBrokerImpl = new RootBindingAwareBroker("test");
+
+        final MountPointService mountService = new BindingDOMMountPointServiceAdapter(biMountImpl, codec);
+        baBrokerImpl.setMountService(mountService);
+        baBrokerImpl.setLegacyMountManager(new HydrogenMountProvisionServiceAdapter(mountService));
+        baBrokerImpl.setRpcBroker(new HeliumRpcProviderRegistry(baConsumerRpc,baProviderRpc));
         baBrokerImpl.setLegacyDataBroker(baData);
         baBrokerImpl.setNotificationBroker(baNotifyImpl);
         baBrokerImpl.start();
     }
 
     public void startForwarding() {
-        checkState(baData != null, "Binding Data Broker needs to be started");
-        checkState(biDataLegacyBroker != null, "DOM Data Broker needs to be started.");
-        checkState(mappingServiceImpl != null, "DOM Mapping Service needs to be started.");
-
-        baConnectImpl = BindingDomConnectorDeployer.createConnector(getBindingToDomMappingService());
-        baConnectImpl.setDomRpcRegistry(getDomRpcRegistry());
-        baBrokerImpl.setConnector(baConnectImpl);
-        baBrokerImpl.setDomProviderContext(createMockContext());
-        baBrokerImpl.startForwarding();
+
     }
 
     private ProviderSession createMockContext() {
@@ -194,7 +192,7 @@ public class BindingTestContext implements AutoCloseable {
                 //
                 .put(org.opendaylight.controller.sal.core.api.data.DataProviderService.class, biDataLegacyBroker) //
                 .put(RpcProvisionRegistry.class, biBrokerImpl.getRouter()) //
-                .put(MountProvisionService.class, biMountImpl) //
+                .put(DOMMountPointService.class, biMountImpl)
                 .build();
 
         return new ProviderSession() {
@@ -252,9 +250,9 @@ public class BindingTestContext implements AutoCloseable {
         mappingServiceImpl = new RuntimeGeneratedMappingServiceImpl(classPool);
         mockSchemaService.registerSchemaContextListener(mappingServiceImpl);
 
-        DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(classPool));
-        BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(generator);
-        GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
+        final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(classPool));
+        final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(generator);
+        final GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
         codec = new BindingToNormalizedNodeCodec(loading, mappingServiceImpl, codecRegistry);
         mockSchemaService.registerSchemaContextListener(codec);
     }
@@ -264,7 +262,7 @@ public class BindingTestContext implements AutoCloseable {
     }
 
     private SchemaContext getContext(final ImmutableSet<YangModuleInfo> moduleInfos) {
-        ModuleInfoBackedContext ctx = ModuleInfoBackedContext.create();
+        final ModuleInfoBackedContext ctx = ModuleInfoBackedContext.create();
         ctx.addModuleInfos(moduleInfos);
         return ctx.tryToCreateSchemaContext().get();
     }
@@ -287,20 +285,25 @@ public class BindingTestContext implements AutoCloseable {
     }
 
     public void startNewBindingDataBroker() {
-        ForwardedBackwardsCompatibleDataBroker forwarded = new ForwardedBackwardsCompatibleDataBroker(newDOMDataBroker, codec,mockSchemaService, executor);
+        final HydrogenDataBrokerAdapter forwarded = new HydrogenDataBrokerAdapter(dataBroker);
         baData = forwarded;
     }
 
     private void startDomMountPoint() {
-        biMountImpl = new MountPointManagerImpl();
-        biMountImpl.setDataBroker(getDomDataBroker());
+        biMountImpl = new DOMMountPointServiceImpl();
     }
 
     private void startDomBroker() {
         checkState(executor != null);
 
-        SchemaAwareRpcBroker router = new SchemaAwareRpcBroker("/", mockSchemaService);
-        ClassToInstanceMap<BrokerService> services = MutableClassToInstanceMap.create();
+        final SchemaAwareRpcBroker router = new SchemaAwareRpcBroker("/", mockSchemaService);
+
+        domRouter = new DOMRpcRouter();
+        mockSchemaService.registerSchemaContextListener(domRouter);
+
+        final ClassToInstanceMap<BrokerService> services = MutableClassToInstanceMap.create();
+        services.put(DOMRpcService.class, domRouter);
+
         biBrokerImpl = new BrokerImpl(router,services);
 
     }
@@ -312,7 +315,7 @@ public class BindingTestContext implements AutoCloseable {
     }
 
     public void loadYangSchemaFromClasspath() {
-        ImmutableSet<YangModuleInfo> moduleInfos = BindingReflections.loadModuleInfos();
+        final ImmutableSet<YangModuleInfo> moduleInfos = BindingReflections.loadModuleInfos();
         updateYangSchema(moduleInfos);
     }
 
@@ -334,15 +337,12 @@ public class BindingTestContext implements AutoCloseable {
         return baBrokerImpl.getRoot();
     }
 
-    public RpcProvisionRegistry getDomRpcRegistry() {
-        if (biBrokerImpl == null) {
-            return null;
-        }
-        return biBrokerImpl.getRouter();
+    public DOMRpcProviderService getDomRpcRegistry() {
+        return domRouter;
     }
 
-    public RpcImplementation getDomRpcInvoker() {
-        return biBrokerImpl.getRouter();
+    public DOMRpcService getDomRpcInvoker() {
+        return domRouter;
     }
 
     @Override
@@ -351,10 +351,10 @@ public class BindingTestContext implements AutoCloseable {
     }
 
     public MountProviderService getBindingMountProviderService() {
-        return baBrokerImpl.getMountManager();
+        return baBrokerImpl.getLegacyMount();
     }
 
-    public MountProvisionService getDomMountProviderService() {
+    public DOMMountPointService getDomMountProviderService() {
         return biMountImpl;
     }
 
index f199d71..ee9f006 100644 (file)
@@ -10,18 +10,31 @@ package org.opendaylight.controller.sal.binding.test.connect.dom;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collections;
 import java.util.Map;
-
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.data.DataReader;
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
 import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
 import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
 import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugment;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.TllComplexAugment;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1;
@@ -32,12 +45,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
-
-import com.google.common.util.concurrent.MoreExecutors;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 
 @SuppressWarnings("deprecation")
 public class CrossBrokerMountPointTest {
@@ -70,6 +87,7 @@ public class CrossBrokerMountPointTest {
     private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier TLL_INSTANCE_ID_BI = //
     org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.builder() //
             .node(Top.QNAME) //
+            .node(TopLevelList.QNAME) //
             .nodeWithKey(TopLevelList.QNAME, TLL_KEY_BI) //
             .build();
 
@@ -84,11 +102,11 @@ public class CrossBrokerMountPointTest {
 
     private BindingTestContext testContext;
     private MountProviderService bindingMountPointService;
-    private MountProvisionService domMountPointService;
+    private DOMMountPointService domMountPointService;
 
     @Before
     public void setup() {
-        BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory();
+        final BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory();
         testFactory.setExecutor(MoreExecutors.sameThreadExecutor());
         testFactory.setStartWithParsedSchema(true);
         testContext = testFactory.getTestContext();
@@ -106,44 +124,104 @@ public class CrossBrokerMountPointTest {
 
     @Test
     public void testMountPoint() {
+        final Integer attrIntValue = 500;
+        domMountPointService.createMountPoint(TLL_INSTANCE_ID_BI)
+            .addService(DOMDataBroker.class, new DOMDataBroker() {
+
+                @Override
+                public ListenerRegistration<DOMDataChangeListener> registerDataChangeListener(final LogicalDatastoreType store,
+                        final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) {
+                    throw new UnsupportedOperationException();
+                }
 
-        testContext.getBindingDataBroker().readOperationalData(TLL_INSTANCE_ID_BA);
-
-        MountProvisionInstance domMountPoint = domMountPointService.createMountPoint(TLL_INSTANCE_ID_BI);
-        assertNotNull(domMountPoint);
-        MountProviderInstance bindingMountPoint = bindingMountPointService.getMountPoint(TLL_INSTANCE_ID_BA);
-        assertNotNull(bindingMountPoint);
-
-        final Integer attrIntalue = 500;
-
+                @Override
+                public DOMDataWriteTransaction newWriteOnlyTransaction() {
+                    throw new UnsupportedOperationException();
+                }
 
-        DataReader<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> simpleReader = new DataReader<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode>() {
+                @Override
+                public DOMDataReadWriteTransaction newReadWriteTransaction() {
+                    return  new DOMDataReadWriteTransaction() {
+
+                        @Override
+                        public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
+                                final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+                            if(store == LogicalDatastoreType.OPERATIONAL && path.getLastPathArgument().equals(GROUP_STATISTICS_ID_BI.getLastPathArgument())) {
+
+                                final ContainerNode data = Builders.containerBuilder()
+                                        .withNodeIdentifier(new NodeIdentifier(AUG_CONT))
+                                        .withChild(ImmutableNodes.leafNode(QName.create(AUG_CONT, "attr-int"), attrIntValue))
+                                        .build();
+
+                                return Futures.immediateCheckedFuture(Optional.<NormalizedNode<?,?>>of(data));
+                            }
+                            return Futures.immediateFailedCheckedFuture(new ReadFailedException(TLL_NAME, new Exception()));
+                        }
+
+                        @Override
+                        public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
+                                final YangInstanceIdentifier path) {
+                            throw new UnsupportedOperationException();
+                        }
+
+                        @Override
+                        public Object getIdentifier() {
+                            return this;
+                        }
+
+                        @Override
+                        public boolean cancel() {
+                            return false;
+                        }
+
+                        @Override
+                        public ListenableFuture<RpcResult<TransactionStatus>> commit() {
+                            return null;
+                        }
+
+                        @Override
+                        public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+                            throw new UnsupportedOperationException();
+                        }
+
+                        @Override
+                        public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+                                final NormalizedNode<?, ?> data) {
+                            throw new UnsupportedOperationException();
+                        }
+
+                        @Override
+                        public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+                                final NormalizedNode<?, ?> data) {
+                            throw new UnsupportedOperationException();
+                        }
+
+                        @Override
+                        public CheckedFuture<Void, TransactionCommitFailedException> submit() {
+                            throw new UnsupportedOperationException();
+                        }
+
+                    };
+                }
 
-            @Override
-            public CompositeNode readConfigurationData(final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier arg0) {
-                return null;
-            }
+                @Override
+                public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
+                    throw new UnsupportedOperationException();
+                }
 
+                @Override
+                public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
+                    throw new UnsupportedOperationException();
+                }
+            }).register();
 
-            @Override
-            public CompositeNode readOperationalData(final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier arg0) {
-                if (arg0.equals(GROUP_STATISTICS_ID_BI)) {
-                    ImmutableCompositeNode data = ImmutableCompositeNode
-                            .builder()
-                            .setQName(AUG_CONT)
-                            .addLeaf(QName.create(AUG_CONT, "attr-int"), attrIntalue) //
-                            .build();
 
-                    return data;
-                }
-                return null;
-            }
 
-        };
-        domMountPoint.registerOperationalReader(TLL_INSTANCE_ID_BI, simpleReader);
+        final MountProviderInstance bindingMountPoint = bindingMountPointService.getMountPoint(TLL_INSTANCE_ID_BA);
+        assertNotNull(bindingMountPoint);
 
-        Cont data = (Cont) bindingMountPoint.readOperationalData(AUG_CONT_ID_BA);
+        final Cont data = (Cont) bindingMountPoint.readOperationalData(AUG_CONT_ID_BA);
         assertNotNull(data);
-        assertEquals(attrIntalue ,data.getAttrInt());
+        assertEquals(attrIntValue ,data.getAttrInt());
     }
 }
index 83c2f88..63b0484 100644 (file)
@@ -12,18 +12,23 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
 
-import com.google.common.collect.ImmutableSet;
+import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
+import java.util.concurrent.Future;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
 import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
-import org.opendaylight.controller.sal.core.api.RpcImplementation;
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutput;
@@ -38,18 +43,16 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl;
-import java.util.Collections;
-import java.util.Set;
-import java.util.concurrent.Future;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 public class CrossBrokerRpcTest {
 
     protected RpcProviderRegistry providerRegistry;
-    protected RpcProvisionRegistry provisionRegistry;
+    protected DOMRpcProviderService provisionRegistry;
     private BindingTestContext testContext;
-    private RpcImplementation biRpcInvoker;
+    private DOMRpcService biRpcInvoker;
     private MessageCapturingFlowService knockService;
 
     public static final TopLevelListKey NODE_A = new TopLevelListKey("a");
@@ -58,6 +61,7 @@ public class CrossBrokerRpcTest {
 
     private static final QName NODE_ID_QNAME = QName.create(TopLevelList.QNAME, "name");
     private static final QName KNOCK_KNOCK_QNAME = QName.create(KnockKnockOutput.QNAME, "knock-knock");
+    private static final SchemaPath KNOCK_KNOCK_PATH = SchemaPath.create(true, KNOCK_KNOCK_QNAME);
 
     public static final InstanceIdentifier<Top> NODES_PATH = InstanceIdentifier.builder(Top.class).build();
     public static final InstanceIdentifier<TopLevelList> BA_NODE_A_ID = NODES_PATH.child(TopLevelList.class, NODE_A);
@@ -100,11 +104,11 @@ public class CrossBrokerRpcTest {
         KnockKnockInput knockKnockA = knockKnock(BA_NODE_A_ID) //
                 .setQuestion("who's there?").build();
 
-        CompositeNode knockKnockDom = toDomRpc(KNOCK_KNOCK_QNAME, knockKnockA);
+        ContainerNode knockKnockDom = toDomRpc(KNOCK_KNOCK_QNAME, knockKnockA);
         assertNotNull(knockKnockDom);
-        RpcResult<CompositeNode> domResult = biRpcInvoker.invokeRpc(KNOCK_KNOCK_QNAME, knockKnockDom).get();
+        DOMRpcResult domResult = biRpcInvoker.invokeRpc(KNOCK_KNOCK_PATH, knockKnockDom).get();
         assertNotNull(domResult);
-        assertTrue("DOM result is successful.", domResult.isSuccessful());
+        assertNotNull("DOM result is successful.", domResult.getResult());
         assertTrue("Bidning Add Flow RPC was captured.", knockService.getReceivedKnocks().containsKey(BA_NODE_A_ID));
         assertEquals(knockKnockA, knockService.getReceivedKnocks().get(BA_NODE_A_ID).iterator().next());
     }
@@ -114,20 +118,15 @@ public class CrossBrokerRpcTest {
         KnockKnockOutputBuilder builder = new KnockKnockOutputBuilder();
         builder.setAnswer("open");
         final KnockKnockOutput output = builder.build();
-        org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration registration = provisionRegistry.addRoutedRpcImplementation(KNOCK_KNOCK_QNAME, new RpcImplementation() {
-            @Override
-            public Set<QName> getSupportedRpcs() {
-                return ImmutableSet.of(KNOCK_KNOCK_QNAME);
-            }
+
+        provisionRegistry.registerRpcImplementation(new DOMRpcImplementation() {
 
             @Override
-            public ListenableFuture<RpcResult<CompositeNode>> invokeRpc(QName rpc, CompositeNode input) {
-                CompositeNode result = testContext.getBindingToDomMappingService().toDataDom(output);
-                return Futures.immediateFuture(RpcResultBuilder.<CompositeNode>success(result).build());
+            public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(DOMRpcIdentifier rpc, NormalizedNode<?, ?> input) {
+                ContainerNode result = testContext.getCodec().getCodecFactory().toNormalizedNodeRpcData(output);
+                return Futures.<DOMRpcResult, DOMRpcException>immediateCheckedFuture(new DefaultDOMRpcResult(result));
             }
-        });
-        registration.registerPath(TestContext.QNAME, BI_NODE_C_ID);
-
+        }, DOMRpcIdentifier.create(KNOCK_KNOCK_PATH, BI_NODE_C_ID));
 
         OpendaylightOfMigrationTestModelService baKnockInvoker =
                 providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class);
@@ -136,8 +135,8 @@ public class CrossBrokerRpcTest {
         assertEquals(output, baResult.get().getResult());
     }
 
-    private CompositeNode toDomRpcInput(DataObject addFlowA) {
-        return testContext.getBindingToDomMappingService().toDataDom(addFlowA);
+    private ContainerNode toDomRpcInput(DataObject addFlowA) {
+        return testContext.getCodec().getCodecFactory().toNormalizedNodeRpcData(addFlowA);
     }
 
     @After
@@ -147,7 +146,8 @@ public class CrossBrokerRpcTest {
 
     private static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier createBINodeIdentifier(TopLevelListKey listKey) {
         return org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.builder().node(Top.QNAME)
-                .nodeWithKey(TopLevelList.QNAME, NODE_ID_QNAME, listKey.getName()).toInstance();
+                .node(TopLevelList.QNAME)
+                .nodeWithKey(TopLevelList.QNAME, NODE_ID_QNAME, listKey.getName()).build();
     }
 
     private Future<RpcResult<KnockKnockOutput>> knockResult(boolean success, String answer) {
@@ -163,8 +163,7 @@ public class CrossBrokerRpcTest {
         return builder;
     }
 
-    private CompositeNode toDomRpc(QName rpcName, KnockKnockInput knockInput) {
-        return new CompositeNodeTOImpl(rpcName, null,
-                Collections.<org.opendaylight.yangtools.yang.data.api.Node<?>>singletonList(toDomRpcInput(knockInput)));
+    private ContainerNode toDomRpc(QName rpcName, KnockKnockInput knockInput) {
+        return toDomRpcInput(knockInput);
     }
 }
index 7595ec0..a0f4e99 100644 (file)
@@ -11,44 +11,45 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.io.InputStream;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
 import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
 import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
 import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
 import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
-import org.opendaylight.controller.sal.core.api.RpcImplementation;
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
-import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-
 /**
  * Test case for reported bug 560
  *
@@ -70,7 +71,7 @@ public class DOMRpcServiceTestBugfix560 {
     private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier BI_MOUNT_ID = createBITllIdentifier(TLL_NAME);
 
     private BindingTestContext testContext;
-    private MountProvisionService domMountPointService;
+    private DOMMountPointService domMountPointService;
     private MountProviderService bindingMountPointService;
     private SchemaContext schemaContext;
 
@@ -79,7 +80,7 @@ public class DOMRpcServiceTestBugfix560 {
      */
     @Before
     public void setUp() throws Exception {
-        BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory();
+        final BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory();
         testFactory.setExecutor(MoreExecutors.sameThreadExecutor());
         testFactory.setStartWithParsedSchema(true);
         testContext = testFactory.getTestContext();
@@ -95,10 +96,12 @@ public class DOMRpcServiceTestBugfix560 {
                 .getModuleSourceStream();
 
         assertNotNull(moduleStream);
-        List<InputStream> rpcModels = Collections.singletonList(moduleStream);
+        final List<InputStream> rpcModels = Collections.singletonList(moduleStream);
         @SuppressWarnings("deprecation")
+        final
         Set<Module> modules = parser.parseYangModelsFromStreams(rpcModels);
         @SuppressWarnings("deprecation")
+        final
         SchemaContext mountSchemaContext = parser.resolveSchemaContext(modules);
         schemaContext = mountSchemaContext;
     }
@@ -107,6 +110,7 @@ public class DOMRpcServiceTestBugfix560 {
             final String mount) {
         return org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier
                 .builder().node(Top.QNAME)
+                .node(TopLevelList.QNAME)
                 .nodeWithKey(TopLevelList.QNAME, TLL_NAME_QNAME, mount)
                 .toInstance();
     }
@@ -122,33 +126,22 @@ public class DOMRpcServiceTestBugfix560 {
     public void test() throws ExecutionException, InterruptedException {
         // FIXME: This is made to only make sure instance identifier codec
         // for path is instantiated.
-        testContext.getBindingDataBroker().readOperationalData(BA_MOUNT_ID);
-        final MountProvisionInstance mountPoint = domMountPointService
-                .createMountPoint(BI_MOUNT_ID);
-        mountPoint.setSchemaContext(schemaContext);
-        assertNotNull(mountPoint);
-
-        mountPoint.addRpcImplementation(RPC_NAME, new RpcImplementation() {
-
-            @Override
-            public ListenableFuture<RpcResult<CompositeNode>> invokeRpc(
-                    final QName rpc, final CompositeNode input) {
-
-                return Futures.immediateFuture(RpcResultBuilder
-                        .<CompositeNode> success().build());
-            }
-
-            @Override
-            public Set<QName> getSupportedRpcs() {
-                return ImmutableSet.of(RPC_NAME);
-            }
-        });
-
-        final Set<QName> biSupportedRpcs = mountPoint.getSupportedRpcs();
-        assertNotNull(biSupportedRpcs);
-        assertTrue(!biSupportedRpcs.isEmpty());
-
-        MountProviderInstance mountInstance = bindingMountPointService
+        domMountPointService
+                .createMountPoint(BI_MOUNT_ID).addService(DOMRpcService.class, new DOMRpcService() {
+
+                    @Override
+                    public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(final T arg0) {
+                        // TODO Auto-generated method stub
+                        return null;
+                    }
+
+                    @Override
+                    public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath arg0, final NormalizedNode<?, ?> arg1) {
+                        final DOMRpcResult result = new DefaultDOMRpcResult((NormalizedNode<?, ?>) null);
+                        return Futures.immediateCheckedFuture(result);
+                    }
+                }).register();
+        final MountProviderInstance mountInstance = bindingMountPointService
                 .getMountPoint(BA_MOUNT_ID);
         assertNotNull(mountInstance);
         final OpendaylightTestRpcServiceService rpcService = mountInstance
@@ -156,10 +149,10 @@ public class DOMRpcServiceTestBugfix560 {
         assertNotNull(rpcService);
 
         try {
-            Future<RpcResult<Void>> result = rpcService
+            final Future<RpcResult<Void>> result = rpcService
                     .rockTheHouse(new RockTheHouseInputBuilder().build());
             assertTrue(result.get().isSuccessful());
-        } catch (IllegalStateException ex) {
+        } catch (final IllegalStateException ex) {
             fail("OpendaylightTestRpcServiceService class doesn't contain rockTheHouse method!");
         }
     }
index 7244038..95abee4 100644 (file)
@@ -14,8 +14,10 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
+import com.google.common.util.concurrent.Futures;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mockito;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
@@ -30,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,6 +59,10 @@ public class RoutedServiceTest extends AbstractTest {
     public void setUp() {
         odlRoutedService1 = mock(OpendaylightTestRoutedRpcService.class, "First Flow Service");
         odlRoutedService2 = mock(OpendaylightTestRoutedRpcService.class, "Second Flow Service");
+        Mockito.when(odlRoutedService1.routedSimpleRoute(Mockito.<RoutedSimpleRouteInput>any()))
+            .thenReturn(Futures.<RpcResult<Void>>immediateFuture(null));
+        Mockito.when(odlRoutedService2.routedSimpleRoute(Mockito.<RoutedSimpleRouteInput>any()))
+            .thenReturn(Futures.<RpcResult<Void>>immediateFuture(null));
     }
 
     @Test
@@ -63,9 +70,9 @@ public class RoutedServiceTest extends AbstractTest {
 
         assertNotNull(getBroker());
 
-        BindingAwareProvider provider1 = new AbstractTestProvider() {
+        final BindingAwareProvider provider1 = new AbstractTestProvider() {
             @Override
-            public void onSessionInitiated(ProviderContext session) {
+            public void onSessionInitiated(final ProviderContext session) {
                 assertNotNull(session);
                 firstReg = session.addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService1);
             }
@@ -76,9 +83,9 @@ public class RoutedServiceTest extends AbstractTest {
         assertNotNull("Registration should not be null", firstReg);
         assertSame(odlRoutedService1, firstReg.getInstance());
 
-        BindingAwareProvider provider2 = new AbstractTestProvider() {
+        final BindingAwareProvider provider2 = new AbstractTestProvider() {
             @Override
-            public void onSessionInitiated(ProviderContext session) {
+            public void onSessionInitiated(final ProviderContext session) {
                 assertNotNull(session);
                 secondReg = session.addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService2);
             }
@@ -90,9 +97,9 @@ public class RoutedServiceTest extends AbstractTest {
         assertSame(odlRoutedService2, secondReg.getInstance());
         assertNotSame(secondReg, firstReg);
 
-        BindingAwareConsumer consumer = new BindingAwareConsumer() {
+        final BindingAwareConsumer consumer = new BindingAwareConsumer() {
             @Override
-            public void onSessionInitialized(ConsumerContext session) {
+            public void onSessionInitialized(final ConsumerContext session) {
                 consumerService = session.getRpcService(OpendaylightTestRoutedRpcService.class);
             }
         };
@@ -102,7 +109,7 @@ public class RoutedServiceTest extends AbstractTest {
         assertNotNull("MD-SAL instance of test Service should be returned", consumerService);
         assertNotSame("Provider instance and consumer instance should not be same.", odlRoutedService1, consumerService);
 
-        InstanceIdentifier<UnorderedList> nodeOnePath = createNodeRef("foo:node:1");
+        final InstanceIdentifier<UnorderedList> nodeOnePath = createNodeRef("foo:node:1");
 
         LOG.info("Provider 1 registers path of node 1");
         firstReg.registerPath(TestContext.class, nodeOnePath);
@@ -111,7 +118,7 @@ public class RoutedServiceTest extends AbstractTest {
          * Consumer creates addFlow message for node one and sends it to the
          * MD-SAL
          */
-        RoutedSimpleRouteInput simpleRouteFirstFoo = createSimpleRouteInput(nodeOnePath);
+        final RoutedSimpleRouteInput simpleRouteFirstFoo = createSimpleRouteInput(nodeOnePath);
         consumerService.routedSimpleRoute(simpleRouteFirstFoo);
 
         /**
@@ -125,14 +132,14 @@ public class RoutedServiceTest extends AbstractTest {
         verify(odlRoutedService2, times(0)).routedSimpleRoute(simpleRouteFirstFoo);
 
         LOG.info("Provider 2 registers path of node 2");
-        InstanceIdentifier<UnorderedList> nodeTwo = createNodeRef("foo:node:2");
+        final InstanceIdentifier<UnorderedList> nodeTwo = createNodeRef("foo:node:2");
         secondReg.registerPath(TestContext.class, nodeTwo);
 
         /**
          * Consumer sends message to nodeTwo for three times. Should be
          * processed by second instance.
          */
-        RoutedSimpleRouteInput simpleRouteSecondFoo = createSimpleRouteInput(nodeTwo);
+        final RoutedSimpleRouteInput simpleRouteSecondFoo = createSimpleRouteInput(nodeTwo);
         consumerService.routedSimpleRoute(simpleRouteSecondFoo);
         consumerService.routedSimpleRoute(simpleRouteSecondFoo);
         consumerService.routedSimpleRoute(simpleRouteSecondFoo);
@@ -154,7 +161,7 @@ public class RoutedServiceTest extends AbstractTest {
         /**
          * A consumer sends third message to node 1
          */
-        RoutedSimpleRouteInput simpleRouteThirdFoo = createSimpleRouteInput(nodeOnePath);
+        final RoutedSimpleRouteInput simpleRouteThirdFoo = createSimpleRouteInput(nodeOnePath);
         consumerService.routedSimpleRoute(simpleRouteThirdFoo);
 
         /**
@@ -174,9 +181,9 @@ public class RoutedServiceTest extends AbstractTest {
      *            string with key(path)
      * @return instance identifier to {@link UnorderedList}
      */
-    private static InstanceIdentifier<UnorderedList> createNodeRef(String string) {
-        UnorderedListKey key = new UnorderedListKey(string);
-        InstanceIdentifier<UnorderedList> path = InstanceIdentifier.builder(Lists.class)
+    private static InstanceIdentifier<UnorderedList> createNodeRef(final String string) {
+        final UnorderedListKey key = new UnorderedListKey(string);
+        final InstanceIdentifier<UnorderedList> path = InstanceIdentifier.builder(Lists.class)
                 .child(UnorderedContainer.class)
                 .child(UnorderedList.class, key)
                 .build();
@@ -191,8 +198,8 @@ public class RoutedServiceTest extends AbstractTest {
      *            NodeRef value
      * @return simpleRouteInput instance
      */
-    static RoutedSimpleRouteInput createSimpleRouteInput(InstanceIdentifier<UnorderedList> node) {
-        RoutedSimpleRouteInputBuilder ret = new RoutedSimpleRouteInputBuilder();
+    static RoutedSimpleRouteInput createSimpleRouteInput(final InstanceIdentifier<UnorderedList> node) {
+        final RoutedSimpleRouteInputBuilder ret = new RoutedSimpleRouteInputBuilder();
         ret.setRoute(node);
         return ret.build();
     }
index 1b5aca2..f9c4a04 100644 (file)
                             <name>runtime-mapping-singleton</name>
                         </module>
                         <module>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-adapter</type>
+                    <name>binding-notification-adapter</name>
+                    <binding-notification-adapter xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                        <binding-mapping-service>
+                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
+                            <name>runtime-mapping-singleton</name>
+                        </binding-mapping-service>
+                        <dom-async-broker>
+                            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
+                            <name>dom-broker</name>
+                        </dom-async-broker>
+                    </binding-notification-adapter>
+                </module>
+                <module>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-publish-adapter</type>
+                    <name>binding-notification-publish-adapter</name>
+                    <binding-notification-publish-adapter xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                        <binding-mapping-service>
+                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
+                            <name>runtime-mapping-singleton</name>
+                        </binding-mapping-service>
+                        <dom-async-broker>
+                            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
+                            <name>dom-broker</name>
+                        </dom-async-broker>
+                    </binding-notification-publish-adapter>
+                </module>
+                <module>
                             <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
                             <name>binding-notification-broker</name>
                         </module>
                         <module>
                             <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
                             <name>binding-broker-impl</name>
-                            <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                    <binding-broker-impl xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                        <binding-mapping-service>
+                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
+                            <name>runtime-mapping-singleton</name>
+                        </binding-mapping-service>
+                        <dom-async-broker>
+                            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
+                            <name>dom-broker</name>
+                        </dom-async-broker>
+                        <notification-service>
                                 <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
                                 <name>binding-notification-broker</name>
                             </notification-service>
-                            <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                        <data-broker>
                                 <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
                                 <name>binding-data-broker</name>
                             </data-broker>
+                        <root-data-broker>
+                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+                        <name>binding-data-broker</name>
+                    </root-data-broker>
+                    </binding-broker-impl>
+                </module>
+
+
+                <module>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider">prefix:inmemory-config-datastore-provider</type>
+                    <name>config-store-service</name>
+                    <inmemory-config-datastore-provider xmlns="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider">
+                        <schema-service>
+                            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+                            <name>yang-schema-service</name>
+                        </schema-service>
+                    </inmemory-config-datastore-provider>
+                </module>
+
+                <module>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider">prefix:inmemory-operational-datastore-provider</type>
+                    <name>operational-store-service</name>
+                    <inmemory-operational-datastore-provider xmlns="urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider">
+                        <schema-service>
+                             <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+                             <name>yang-schema-service</name>
+                        </schema-service>
+                    </inmemory-operational-datastore-provider>
+                </module>
+
+                <!-- PingPong broker -->
+                <module>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:pingpong">prefix:pingpong-data-broker</type>
+                    <name>pingpong-data-broker</name>
+                    <data-broker>
+                        <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type>
+                        <name>inmemory-data-broker</name>
+                    </data-broker>
+                </module>
+                <module>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-forwarded-data-broker</type>
+                    <name>pingpong-binding-data-broker</name>
+                    <binding-forwarded-data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                        <dom-async-broker>
+                            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type>
+                            <name>pingpong-broker</name>
+                        </dom-async-broker>
+                        <schema-service>
+                            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+                            <name>yang-schema-service</name>
+                        </schema-service>
+                        <binding-mapping-service>
+                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
+                            <name>runtime-mapping-singleton</name>
+                        </binding-mapping-service>
+                    </binding-forwarded-data-broker>
                         </module>
+
                         <!--
                              Tree-based in-memory data store. This is the data store which is currently
                              recommended for single-node deployments.
                         <module>
                             <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-compatible-broker</type>
                             <name>inmemory-binding-data-broker</name>
-                            <dom-async-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                                <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-                                <name>dom-broker</name>
-                            </dom-async-broker>
-                            <binding-mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
-                                <name>runtime-mapping-singleton</name>
-                            </binding-mapping-service>
+                    <binding-data-compatible-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                        <data-broker>
+                            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+                            <name>binding-data-broker</name>
+                        </data-broker>
+                    </binding-data-compatible-broker>
                         </module>
                         <module>
                             <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-forwarded-data-broker</type>
                                 <provider>/modules/module[type='schema-service-singleton'][name='yang-schema-service']</provider>
                             </instance>
                         </service>
+
+                <service>
+                    <type xmlns:config-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store">config-dom-store-spi:config-dom-datastore</type>
+                    <instance>
+                        <name>config-store-service</name>
+                        <provider>/modules/module[type='inmemory-config-datastore-provider'][name='config-store-service']</provider>
+                    </instance>
+                </service>
+                <service>
+                    <type xmlns:operational-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store">operational-dom-store-spi:operational-dom-datastore</type>
+                    <instance>
+                        <name>operational-store-service</name>
+                        <provider>/modules/module[type='inmemory-operational-datastore-provider'][name='operational-store-service']</provider>
+                    </instance>
+                </service>
                         <service>
                             <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-dom-mapping-service</type>
                             <instance>
                             </instance>
                         </service>
                         <service>
+                        <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-new-notification-service</type>
+                        <instance>
+                            <name>binding-notification-adapter</name>
+                            <provider>/modules/module[type='binding-notification-adapter'][name='binding-notification-adapter']</provider>
+                        </instance>
+                    </service>
+                    <service>
+                        <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-new-notification-publish-service</type>
+                        <instance>
+                            <name>binding-notification-publish-adapter</name>
+                            <provider>/modules/module[type='binding-notification-publish-adapter'][name='binding-notification-publish-adapter']</provider>
+                        </instance>
+                    </service>
+                    <service>