Add blueprint wiring to netconf-notification-impl 52/45752/21
authorAlexis de Talhouët <adetalhouet@inocybe.com>
Wed, 26 Oct 2016 15:03:20 +0000 (11:03 -0400)
committerAlexis de Talhouët <adetalhouet@inocybe.com>
Mon, 31 Oct 2016 15:43:43 +0000 (11:43 -0400)
- add the mdsal-notification-mapper blueprint xml file in mdsal-netconf-notification,
as this bundle is pulled in by the odl-netconf-mdsal feature, loading the config system
file responsible to create the modules.

Change-Id: I67fb0be3e9765177bb34f81461978954b4632a53
Signed-off-by: Alexis de Talhouët <adetalhouet@inocybe.com>
netconf/mdsal-netconf-notification/pom.xml
netconf/mdsal-netconf-notification/src/main/resources/org/opendaylight/blueprint/mdsal-notification-mapper.xml [new file with mode: 0755]
netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml
netconf/netconf-notifications-api/src/main/yang/netconf-northbound-notification.yang
netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModule.java
netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModuleFactory.java

index d229c316a3cf6fa0467483a678ebaef14e8ea2ea..40b561c2a3901c727dec27a2a356ddb332755e7a 100644 (file)
             <artifactId>mockito-configuration</artifactId>
         </dependency>
     </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Embed-Dependency>netconf-notifications-impl</Embed-Dependency>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>
diff --git a/netconf/mdsal-netconf-notification/src/main/resources/org/opendaylight/blueprint/mdsal-notification-mapper.xml b/netconf/mdsal-netconf-notification/src/main/resources/org/opendaylight/blueprint/mdsal-notification-mapper.xml
new file mode 100755 (executable)
index 0000000..e21f07d
--- /dev/null
@@ -0,0 +1,37 @@
+<?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:restart-dependents-on-updates="true">
+
+    <!--This is the MD-SAL netconf server notification mapper blueprint xml file-->
+
+    <bean id="netconfNotificationManager"
+          class="org.opendaylight.netconf.notifications.impl.NetconfNotificationManager"
+          destroy-method="close">
+    </bean>
+    <service ref="netconfNotificationManager"
+             interface="org.opendaylight.netconf.notifications.NetconfNotificationRegistry"
+             odl:type="netconf-notification-manager">
+        <service-properties>
+            <entry key="config-module-namespace" value="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification"/>
+            <entry key="config-module-name" value="netconf-notification-registry"/>
+            <entry key="config-instance-name" value="netconf-notification-manager"/>
+        </service-properties>
+    </service>
+    <service ref="netconfNotificationManager"
+             interface="org.opendaylight.netconf.notifications.NetconfNotificationCollector"
+             odl:type="netconf-notification-manager">
+        <service-properties>
+            <entry key="config-module-namespace" value="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification"/>
+            <entry key="config-module-name" value="netconf-notification-collector"/>
+            <entry key="config-instance-name" value="netconf-notification-manager"/>
+        </service-properties>
+    </service>
+</blueprint>
index 2796dd9bc7d7992a0594d7504ccd7e3e80c002cf..b6e0788ea95db996cc9cc99c10fb584648c80c04 100644 (file)
     </data>
   </configuration>
   <required-capabilities>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification?module=netconf-northbound-notification&amp;revision=2015-08-06</capability>
       <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:mapper?module=netconf-mdsal-mapper&amp;revision=2015-01-14</capability>
       <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring?module=netconf-mdsal-monitoring&amp;revision=2015-02-18</capability>
       <capability>urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:tcp?module=netconf-northbound-tcp&amp;revision=2015-04-23</capability>
index fe0e09e8a787d6ca27777eec0c3d790dc3034bd3..f821a31dc88d83068de697dd0e276faa565338fe 100644 (file)
@@ -16,10 +16,14 @@ module netconf-northbound-notification {
     identity netconf-notification-collector {
             base "config:service-type";
             config:java-class "org.opendaylight.netconf.notifications.NetconfNotificationCollector";
+            config:disable-osgi-service-registration;
+            status deprecated;
         }
 
     identity netconf-notification-registry {
            base "config:service-type";
            config:java-class "org.opendaylight.netconf.notifications.NetconfNotificationRegistry";
+           config:disable-osgi-service-registration;
+           status deprecated;
     }
 }
\ No newline at end of file
index d9dce4b99d95327b0ef5a4326fa7a38573d817e2..fd233e81aa962d4d1ba97aa2cc1a0fc89f27abcb 100644 (file)
@@ -8,9 +8,22 @@
 
 package org.opendaylight.controller.config.yang.netconf.northbound.notification.impl;
 
-import org.opendaylight.netconf.notifications.impl.NetconfNotificationManager;
+import com.google.common.reflect.AbstractInvocationHandler;
+import com.google.common.reflect.Reflection;
+import java.lang.reflect.Method;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
+import org.opendaylight.netconf.notifications.NetconfNotificationRegistry;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class NetconfNotificationManagerModule extends AbstractNetconfNotificationManagerModule {
+
+    private BundleContext bundleContext;
 
-public class NetconfNotificationManagerModule extends org.opendaylight.controller.config.yang.netconf.northbound.notification.impl.AbstractNetconfNotificationManagerModule {
     public NetconfNotificationManagerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
@@ -26,7 +39,29 @@ public class NetconfNotificationManagerModule extends org.opendaylight.controlle
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        return new NetconfNotificationManager();
+
+        final WaitingServiceTracker<NetconfNotificationCollector> tracker =
+                WaitingServiceTracker.create(NetconfNotificationCollector.class, bundleContext, "(type=netconf-notification-manager)");
+        final NetconfNotificationCollector service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+        return Reflection.newProxy(AutoCloseableNetconfNotification.class, new AbstractInvocationHandler() {
+            @Override
+            protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
+                if (method.getName().equals("close")) {
+                    tracker.close();
+                    return null;
+                } else {
+                    return method.invoke(service, args);
+                }
+            }
+        });
+    }
+
+    void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    private static interface AutoCloseableNetconfNotification extends NetconfNotificationCollector, NetconfNotificationRegistry, AutoCloseable {
     }
 
 }
index dadf7562006e935300970cffef73e4586b93c0c8..d6802b3f5ce11fe64c349be3986f7deaab3f0faf 100644 (file)
 * Do not modify this file unless it is present under src/main directory
 */
 package org.opendaylight.controller.config.yang.netconf.northbound.notification.impl;
-public class NetconfNotificationManagerModuleFactory extends org.opendaylight.controller.config.yang.netconf.northbound.notification.impl.AbstractNetconfNotificationManagerModuleFactory {
 
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class NetconfNotificationManagerModuleFactory extends AbstractNetconfNotificationManagerModuleFactory {
+
+    @Override
+    public NetconfNotificationManagerModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+                                                              NetconfNotificationManagerModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+        NetconfNotificationManagerModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule,
+                oldInstance, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+
+    @Override
+    public NetconfNotificationManagerModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+                                                           BundleContext bundleContext) {
+        NetconfNotificationManagerModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
 }