From a0698c9ba2dc5303e8f5783a3d6715c5bad0049f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20de=20Talhou=C3=ABt?= Date: Wed, 26 Oct 2016 11:03:20 -0400 Subject: [PATCH] Add blueprint wiring to netconf-notification-impl MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - 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 --- netconf/mdsal-netconf-notification/pom.xml | 16 ++++++++ .../blueprint/mdsal-notification-mapper.xml | 37 +++++++++++++++++ .../resources/initial/08-netconf-mdsal.xml | 1 + .../yang/netconf-northbound-notification.yang | 4 ++ .../NetconfNotificationManagerModule.java | 41 +++++++++++++++++-- ...tconfNotificationManagerModuleFactory.java | 26 +++++++++++- 6 files changed, 121 insertions(+), 4 deletions(-) create mode 100755 netconf/mdsal-netconf-notification/src/main/resources/org/opendaylight/blueprint/mdsal-notification-mapper.xml diff --git a/netconf/mdsal-netconf-notification/pom.xml b/netconf/mdsal-netconf-notification/pom.xml index d229c316a3..40b561c2a3 100644 --- a/netconf/mdsal-netconf-notification/pom.xml +++ b/netconf/mdsal-netconf-notification/pom.xml @@ -69,4 +69,20 @@ mockito-configuration + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + netconf-notifications-impl + + + + + 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 index 0000000000..e21f07dd62 --- /dev/null +++ b/netconf/mdsal-netconf-notification/src/main/resources/org/opendaylight/blueprint/mdsal-notification-mapper.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml b/netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml index 2796dd9bc7..b6e0788ea9 100644 --- a/netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml +++ b/netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml @@ -163,6 +163,7 @@ + urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification?module=netconf-northbound-notification&revision=2015-08-06 urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:mapper?module=netconf-mdsal-mapper&revision=2015-01-14 urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:monitoring?module=netconf-mdsal-monitoring&revision=2015-02-18 urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:tcp?module=netconf-northbound-tcp&revision=2015-04-23 diff --git a/netconf/netconf-notifications-api/src/main/yang/netconf-northbound-notification.yang b/netconf/netconf-notifications-api/src/main/yang/netconf-northbound-notification.yang index fe0e09e8a7..f821a31dc8 100644 --- a/netconf/netconf-notifications-api/src/main/yang/netconf-northbound-notification.yang +++ b/netconf/netconf-notifications-api/src/main/yang/netconf-northbound-notification.yang @@ -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 diff --git a/netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModule.java b/netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModule.java index d9dce4b99d..fd233e81aa 100644 --- a/netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModule.java +++ b/netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModule.java @@ -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 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 { } } diff --git a/netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModuleFactory.java b/netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModuleFactory.java index dadf756200..d6802b3f5c 100644 --- a/netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModuleFactory.java +++ b/netconf/netconf-notifications-impl/src/main/java/org/opendaylight/controller/config/yang/netconf/northbound/notification/impl/NetconfNotificationManagerModuleFactory.java @@ -16,6 +16,30 @@ * 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; + } } -- 2.36.6