Bug 868: Binding MD-SAL exports new codec factory. 71/16771/2
authorTony Tkacik <ttkacik@cisco.com>
Wed, 18 Mar 2015 14:21:09 +0000 (15:21 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Thu, 19 Mar 2015 11:24:36 +0000 (12:24 +0100)
Migrated MD-SAL to export BindingCodecTreeFactory,
which provides access to new codecs, which allows
us to migrate users without need to change initial
configuration.

Change-Id: Icb741dd73e3b22f64f5f538236d36a99e9c05b4e
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
opendaylight/md-sal/md-sal-config/src/main/resources/initial/01-md-sal.xml
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcProviderServiceAdapter.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcServiceAdapter.java
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/ForwardedNotificationService.java
opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang
opendaylight/md-sal/sal-binding-config/pom.xml
opendaylight/md-sal/sal-binding-config/src/main/yang/opendaylight-md-sal-binding.yang

index 8d5d525..5ef6a24 100644 (file)
                             <provider>/modules/module[type='runtime-generated-mapping'][name='runtime-mapping-singleton']</provider>
                         </instance>
                     </service>
+                    <service>
+                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-codec-tree-factory</type>
+                        <instance>
+                            <name>runtime-mapping-singleton</name>
+                            <provider>/modules/module[type='runtime-generated-mapping'][name='runtime-mapping-singleton']</provider>
+                        </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>
index 46bd2f8..ba82298 100644 (file)
@@ -41,7 +41,7 @@ public class BindingDOMRpcProviderServiceAdapter {
     }
 
     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 BindingRpcImplementationAdapter adapter = new BindingRpcImplementationAdapter(codec.getCodecRegistry(), type, implementation);
 
 
         final DOMRpcImplementationRegistration<?> domReg = domRpcRegistry.registerRpcImplementation(adapter, domRpcs);
index 9694bc9..6b64b7e 100644 (file)
@@ -81,7 +81,7 @@ public class BindingDOMRpcServiceAdapter implements RpcConsumerRegistry, Invocat
     @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());
+        return transformFuture(rpc,domFuture,codec.getCodecRegistry());
     }
 
     private RpcServiceAdapter createProxy(final Class<? extends RpcService> key) {
@@ -96,7 +96,7 @@ public class BindingDOMRpcServiceAdapter implements RpcConsumerRegistry, Invocat
             return null;
         }
         final QName rpcInputIdentifier = QName.create(rpc.getLastComponent(),"input");
-        return new LazySerializedContainerNode(rpcInputIdentifier, input, codec.getCodecFactory());
+        return new LazySerializedContainerNode(rpcInputIdentifier, input, codec.getCodecRegistry());
     }
 
     private static ListenableFuture<RpcResult<?>> transformFuture(final SchemaPath rpc,final ListenableFuture<DOMRpcResult> domFuture, final BindingNormalizedNodeCodecRegistry codec) {
index d5b7d05..bf3ac3d 100644 (file)
@@ -17,6 +17,8 @@ import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
 import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
 import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTree;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTreeFactory;
 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;
@@ -37,7 +39,7 @@ 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 {
+public class BindingToNormalizedNodeCodec implements BindingCodecTreeFactory, SchemaContextListener, AutoCloseable {
 
     private final BindingIndependentMappingService bindingToLegacy;
     private final BindingNormalizedNodeCodecRegistry codecRegistry;
@@ -45,8 +47,9 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener,AutoC
     private final GeneratedClassLoadingStrategy classLoadingStrategy;
     private BindingRuntimeContext runtimeContext;
 
-    public BindingToNormalizedNodeCodec(final GeneratedClassLoadingStrategy classLoadingStrategy, final BindingIndependentMappingService mappingService, final BindingNormalizedNodeCodecRegistry codecRegistry) {
-        super();
+    public BindingToNormalizedNodeCodec(final GeneratedClassLoadingStrategy classLoadingStrategy,
+            final BindingIndependentMappingService mappingService,
+            final BindingNormalizedNodeCodecRegistry codecRegistry) {
         this.bindingToLegacy = mappingService;
         this.classLoadingStrategy = classLoadingStrategy;
         this.codecRegistry = codecRegistry;
@@ -188,4 +191,15 @@ public class BindingToNormalizedNodeCodec implements SchemaContextListener,AutoC
         }
         return key.getMethod(methodName);
     }
+
+    @Override
+    public BindingCodecTree create(BindingRuntimeContext context) {
+        return codecRegistry.create(context);
+    }
+
+    @Override
+    public BindingCodecTree create(SchemaContext context, Class<?>... bindingClasses) {
+        return codecRegistry.create(context, bindingClasses);
+    }
+
 }
index 8ce8da8..f0545ca 100644 (file)
@@ -113,7 +113,7 @@ public class ForwardedNotificationService implements NotificationService, AutoCl
                 ClassToInstanceMap<DOMService> delegates) {
             DOMNotificationService domNotification = delegates.getInstance(DOMNotificationService.class);
             NotificationInvokerFactory invokerFactory = SingletonHolder.INVOKER_FACTORY;
-            return new ForwardedNotificationService(codec.getCodecFactory(), domNotification, invokerFactory);
+            return new ForwardedNotificationService(codec.getCodecRegistry(), domNotification, invokerFactory);
         }
 
         @Override
index b62f596..e15cb83 100644 (file)
@@ -69,6 +69,7 @@ module opendaylight-sal-binding-broker-impl {
     identity runtime-generated-mapping {
         base config:module-type;
         config:provided-service binding-dom-mapping-service;
+        config:provided-service sal:binding-codec-tree-factory;
         config:java-name-prefix RuntimeMapping;
     }
 
index 68af914..39aece4 100644 (file)
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-binding-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>binding-data-codec</artifactId>
+    </dependency>
   </dependencies>
 
   <build>
index fcfd6fa..81508d1 100644 (file)
@@ -43,6 +43,11 @@ module opendaylight-md-sal-binding {
         config:java-class "org.opendaylight.controller.sal.binding.api.NotificationProviderService";
     }
 
+    identity binding-codec-tree-factory {
+        base "config:service-type";
+        config:java-class "org.opendaylight.yangtools.binding.data.codec.api.BindingCodecTreeFactory";
+    }
+
     identity binding-notification-subscription-service {
         base "config:service-type";
         config:java-class "org.opendaylight.controller.sal.binding.api.NotificationService";

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.