Add blueprint wiring for mdsal-netconf-yang-library 31/45631/16
authorAlexis de Talhouët <adetalhouet@inocybe.com>
Thu, 15 Sep 2016 13:16:30 +0000 (09:16 -0400)
committerAlexis de Talhouët <adetalhouet@inocybe.com>
Mon, 31 Oct 2016 15:43:43 +0000 (11:43 -0400)
Change-Id: I36f331c6486130f55411fb794625a78780da6268
Signed-off-by: Alexis de Talhouët <adetalhouet@inocybe.com>
netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/yang/library/NetconfMdsalYanglibModule.java [deleted file]
netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/yang/library/NetconfMdsalYanglibModuleFactory.java [deleted file]
netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/netconf/mdsal/yang/library/SchemaServiceToMdsalWriter.java
netconf/mdsal-netconf-yang-library/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-yang-library.xml [new file with mode: 0755]
netconf/mdsal-netconf-yang-library/src/main/yang/netconf-mdsal-yang-library.yang [deleted file]
netconf/mdsal-netconf-yang-library/src/test/java/org/opendaylight/netconf/mdsal/yang/library/SchemaServiceToMdsalWriterTest.java
netconf/netconf-artifacts/pom.xml
netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml

diff --git a/netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/yang/library/NetconfMdsalYanglibModule.java b/netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/yang/library/NetconfMdsalYanglibModule.java
deleted file mode 100644 (file)
index 77492cb..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.config.yang.netconf.mdsal.yang.library;
-
-import org.opendaylight.netconf.mdsal.yang.library.SchemaServiceToMdsalWriter;
-
-public class NetconfMdsalYanglibModule extends org.opendaylight.controller.config.yang.netconf.mdsal.yang.library.AbstractNetconfMdsalYanglibModule {
-    public NetconfMdsalYanglibModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public NetconfMdsalYanglibModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.netconf.mdsal.yang.library.NetconfMdsalYanglibModule oldModule, java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        // TODO Implement also yang-library-change notfication
-        final SchemaServiceToMdsalWriter schemaServiceToMdsalWriter =
-                new SchemaServiceToMdsalWriter(getRootSchemaServiceDependency());
-
-        getBindingAwareBrokerDependency().registerProvider(schemaServiceToMdsalWriter);
-
-        return schemaServiceToMdsalWriter;
-    }
-
-}
diff --git a/netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/yang/library/NetconfMdsalYanglibModuleFactory.java b/netconf/mdsal-netconf-yang-library/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/yang/library/NetconfMdsalYanglibModuleFactory.java
deleted file mode 100644 (file)
index 739485b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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
- */
-
-/*
-* Generated file
-*
-* Generated from: yang module name: netconf-mdsal-yang-library yang module local name: netconf-mdsal-yanglib
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Sun Jun 19 15:28:13 CEST 2016
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.controller.config.yang.netconf.mdsal.yang.library;
-public class NetconfMdsalYanglibModuleFactory extends org.opendaylight.controller.config.yang.netconf.mdsal.yang.library.AbstractNetconfMdsalYanglibModuleFactory {
-
-}
index 44dbdc7cf2d06bc438ac4bb17318c66ec829b1ca..2360369e6af354a1a934dfde79f3867a927c0957 100644 (file)
@@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory;
  * Listens for updates on global schema context, transforms context to ietf-yang-library:modules-state and
  * writes this state to operational data store
  */
-public class SchemaServiceToMdsalWriter implements SchemaContextListener, BindingAwareProvider, AutoCloseable {
+public class SchemaServiceToMdsalWriter implements SchemaContextListener, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(SchemaServiceToMdsalWriter.class);
 
@@ -53,10 +53,12 @@ public class SchemaServiceToMdsalWriter implements SchemaContextListener, Bindin
 
     private final SchemaService schemaService;
     private final AtomicInteger moduleSetId;
-    private DataBroker dataBroker;
+    private final DataBroker dataBroker;
 
-    public SchemaServiceToMdsalWriter(final SchemaService schemaService) {
+    public SchemaServiceToMdsalWriter(final SchemaService schemaService,
+                                      final DataBroker dataBroker) {
         this.schemaService = schemaService;
+        this.dataBroker = dataBroker;
         this.moduleSetId = new AtomicInteger(0);
     }
 
@@ -65,9 +67,10 @@ public class SchemaServiceToMdsalWriter implements SchemaContextListener, Bindin
         // TODO Delete modules-state from operational data store
     }
 
-    @Override
-    public void onSessionInitiated(final BindingAwareBroker.ProviderContext providerContext) {
-        dataBroker = providerContext.getSALService(DataBroker.class);
+    /**
+     * Invoke by blueprint
+     */
+    public void start() {
         schemaService.registerSchemaContextListener(this);
     }
 
diff --git a/netconf/mdsal-netconf-yang-library/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-yang-library.xml b/netconf/mdsal-netconf-yang-library/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-yang-library.xml
new file mode 100755 (executable)
index 0000000..a4a2bf1
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Inocybe Technologies 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           odl:use-default-for-reference-types="true">
+
+    <reference id="dataBroker"
+               interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+               odl:type="default"/>
+    <reference id="schemaService"
+               interface="org.opendaylight.controller.sal.core.api.model.SchemaService" />
+
+    <bean id="schemaServiceToMdsalWriter"
+          class="org.opendaylight.netconf.mdsal.yang.library.SchemaServiceToMdsalWriter"
+          init-method="start"
+          destroy-method="close">
+        <argument ref="schemaService" />
+        <argument ref="dataBroker" />
+    </bean>
+
+</blueprint>
diff --git a/netconf/mdsal-netconf-yang-library/src/main/yang/netconf-mdsal-yang-library.yang b/netconf/mdsal-netconf-yang-library/src/main/yang/netconf-mdsal-yang-library.yang
deleted file mode 100644 (file)
index 407a76d..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-module netconf-mdsal-yang-library {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:yang:library";
-    prefix "nmyanglib";
-
-    import opendaylight-md-sal-dom { prefix md-sal-dom; revision-date 2013-10-28; }
-    import opendaylight-md-sal-binding {prefix md-sal-binding; revision-date 2013-10-28;}
-    import config { prefix config; revision-date 2013-04-05; }
-
-    organization "Cisco Systems, Inc.";
-
-    description
-        "This module contains the base YANG definitions for
-         MDSAL netconf yang module library implementation";
-
-    revision "2016-06-17" {
-        description
-            "Initial revision.";
-    }
-
-    identity netconf-mdsal-yanglib {
-        base config:module-type;
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case netconf-mdsal-yanglib {
-            when "/config:modules/config:module/config:type = 'netconf-mdsal-yanglib'";
-
-            container root-schema-service {
-                uses config:service-ref {
-                    refine type {
-                        mandatory false;
-                        config:required-identity md-sal-dom:schema-service;
-                    }
-                }
-            }
-
-            container binding-aware-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
-                    }
-                }
-            }
-        }
-    }
-}
\ No newline at end of file
index 0e6e60907add2ef8d5c35595ed0fcc0c61afa73f..d531eb63caa4fa1e16bb7038047bde6099b14125 100644 (file)
@@ -81,12 +81,12 @@ public class SchemaServiceToMdsalWriterTest {
                 return null;
             }
         });
-        schemaServiceToMdsalWriter = new SchemaServiceToMdsalWriter(schemaService);
+        schemaServiceToMdsalWriter = new SchemaServiceToMdsalWriter(schemaService, dataBroker);
     }
 
     @Test
     public void testOnGlobalContextUpdated() {
-        schemaServiceToMdsalWriter.onSessionInitiated(context);
+        schemaServiceToMdsalWriter.start();
 
         schemaServiceToMdsalWriter.onGlobalContextUpdated(getSchema());
         verify(writeTransaction).put(eq(LogicalDatastoreType.OPERATIONAL), eq(MODULES_STATE_INSTANCE_IDENTIFIER), eq(createTestModuleState()));
index ab5167abdfc4fce0c8de25fca3cdc601100246a2..42093b47a976d707336b3040a652d07dd8700263 100644 (file)
                 <classifier>config</classifier>
                 <type>xml</type>
             </dependency>
-            <dependency>
-                <groupId>${project.groupId}</groupId>
-                <artifactId>yanglib-config</artifactId>
-                <version>${project.version}</version>
-                <classifier>config</classifier>
-                <type>xml</type>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>netconf-client</artifactId>
index 3618b13e85674f7de0cd5a2072c81be3567ccf7f..19f9d25964528e2364120ed234d3b5215b9cc012 100644 (file)
               <name>netconf-mdsal-notification-mapper</name>
           </module>
 
-          <module>
-              <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:yang:library">prefix:netconf-mdsal-yanglib</type>
-              <name>netconf-mdsal-yanglib</name>
-              <binding-aware-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:yang:library">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
-                  <name>binding-osgi-broker</name>
-              </binding-aware-broker>
-              <root-schema-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:yang:library">
-              <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
-              <name>yang-schema-service</name>
-          </root-schema-service>
-          </module>
-
-
-
           <!--TCP endpoint for MD-SAL netconf server -->
           <!--<module>-->
               <!--<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:tcp">prefix:netconf-northbound-tcp</type>-->
@@ -63,7 +48,6 @@
                   <!--<name>netconf-mdsal-server-dispatcher</name>-->
               <!--</dispatcher>-->
           <!--</module>-->
-
       </modules>
 
         <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
       <capability>urn:opendaylight:params:xml:ns:yang:controller:config:netconf:northbound:impl?module=netconf-northbound-impl&amp;revision=2015-01-12</capability>
       <capability>urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:scheduled?module=threadpool-impl-scheduled&amp;revision=2013-12-01</capability>
       <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification?module=netconf-mdsal-notification&amp;revision=2015-08-03</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:yang:library?module=netconf-mdsal-yang-library&amp;revision=2016-06-17</capability>
   </required-capabilities>
 </snapshot>