Add blueprint wiring to mdsal-netconf-notification 28/45628/18
authorAlexis de Talhouët <adetalhouet@inocybe.com>
Wed, 21 Sep 2016 23:23:28 +0000 (19:23 -0400)
committerAlexis de Talhouët <adetalhouet@inocybe.com>
Mon, 31 Oct 2016 15:43:43 +0000 (11:43 -0400)
Change classes' modifiers to public so they can be instantiated
using blueprint.

Change-Id: I7b9ac6eaca8f8d7ff8b058e257b5092160ba09bb
Signed-off-by: Alexis de Talhouët <adetalhouet@inocybe.com>
13 files changed:
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/CapabilityChangeNotificationProducer.java
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NetconfMdsalNotificationMapperModule.java
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NetconfMdsalNotificationMapperModuleFactory.java
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NotificationToMdsalWriter.java
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/SessionNotificationProducer.java
netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/netconf/mdsal/notification/NetconfNotificationOperationServiceFactory.java
netconf/mdsal-netconf-notification/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-notification.xml [new file with mode: 0755]
netconf/mdsal-netconf-notification/src/main/resources/org/opendaylight/blueprint/mdsal-notification-mapper.xml [deleted file]
netconf/mdsal-netconf-notification/src/main/yang/netconf-mdsal-notification.yang
netconf/mdsal-netconf-notification/src/test/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/CapabilityChangeNotificationProducerTest.java
netconf/mdsal-netconf-notification/src/test/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/NotificationToMdsalWriterTest.java
netconf/mdsal-netconf-notification/src/test/java/org/opendaylight/controller/config/yang/netconf/mdsal/notification/SessionNotificationProducerTest.java
netconf/netconf-mdsal-config/src/main/resources/initial/08-netconf-mdsal.xml

index 2fd48091e9d1934214f47c88062ff879afb050e3..35f5c805aecbfdf39cfdafb19db7751989439b13 100644 (file)
@@ -15,15 +15,18 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Set;
 import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
+import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.ChangedByBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.changed.by.server.or.user.ServerBuilder;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 
@@ -31,15 +34,19 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
  * Listens on capabilities changes in data store and publishes them to base
  * netconf notification stream listener.
  */
-final class CapabilityChangeNotificationProducer extends OperationalDatastoreListener<Capabilities> {
+public final class CapabilityChangeNotificationProducer extends OperationalDatastoreListener<Capabilities> {
 
     private static final InstanceIdentifier<Capabilities> CAPABILITIES_INSTANCE_IDENTIFIER =
             InstanceIdentifier.create(NetconfState.class).child(Capabilities.class);
+
     private final BaseNotificationPublisherRegistration baseNotificationPublisherRegistration;
+    private final ListenerRegistration capabilityChangeListenerRegistration;
 
-    public CapabilityChangeNotificationProducer(BaseNotificationPublisherRegistration baseNotificationPublisherRegistration) {
+    public CapabilityChangeNotificationProducer(final NetconfNotificationCollector netconfNotificationCollector,
+                                                final DataBroker dataBroker) {
         super(CAPABILITIES_INSTANCE_IDENTIFIER);
-        this.baseNotificationPublisherRegistration = baseNotificationPublisherRegistration;
+        this.baseNotificationPublisherRegistration = netconfNotificationCollector.registerBaseNotificationPublisher();
+        this.capabilityChangeListenerRegistration = registerOnChanges(dataBroker);
     }
 
     @Override
@@ -80,4 +87,16 @@ final class CapabilityChangeNotificationProducer extends OperationalDatastoreLis
         netconfCapabilityChangeBuilder.setModifiedCapability(Collections.<Uri>emptyList());
         baseNotificationPublisherRegistration.onCapabilityChanged(netconfCapabilityChangeBuilder.build());
     }
+
+    /**
+     * Invoke by blueprint
+     */
+    public void close() {
+        if (baseNotificationPublisherRegistration != null) {
+            baseNotificationPublisherRegistration.close();
+        }
+        if (capabilityChangeListenerRegistration != null) {
+            capabilityChangeListenerRegistration.close();
+        }
+    }
 }
index 685e80fa54d0196639a07c42dbb48d2faa55dd77..4d4a2d262cd826d9cb39fc8311550ce92f9eaa59 100644 (file)
@@ -8,12 +8,21 @@
 
 package org.opendaylight.controller.config.yang.netconf.mdsal.notification;
 
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.netconf.mdsal.notification.NetconfNotificationOperationServiceFactory;
-import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+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.mapping.api.NetconfOperationServiceFactory;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class NetconfMdsalNotificationMapperModule extends AbstractNetconfMdsalNotificationMapperModule {
+
+    private BundleContext bundleContext;
 
-public class NetconfMdsalNotificationMapperModule extends org.opendaylight.controller.config.yang.netconf.mdsal.notification.AbstractNetconfMdsalNotificationMapperModule {
     public NetconfMdsalNotificationMapperModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
@@ -29,34 +38,27 @@ public class NetconfMdsalNotificationMapperModule extends org.opendaylight.contr
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        final NetconfNotificationCollector notificationCollector = getNotificationCollectorDependency();
-
-        final NotificationToMdsalWriter notificationToMdsalWriter = new NotificationToMdsalWriter(notificationCollector);
-        getBindingAwareBrokerDependency().registerProvider(notificationToMdsalWriter);
-        final DataBroker dataBroker = getDataBrokerDependency();
-
-        final OperationalDatastoreListener capabilityNotificationProducer =
-                new CapabilityChangeNotificationProducer(notificationCollector.registerBaseNotificationPublisher());
-        final ListenerRegistration capabilityChangeListenerRegistration = capabilityNotificationProducer.registerOnChanges(dataBroker);
-
-        final OperationalDatastoreListener sessionNotificationProducer =
-                new SessionNotificationProducer(notificationCollector.registerBaseNotificationPublisher());
-        final ListenerRegistration sessionListenerRegistration = sessionNotificationProducer.registerOnChanges(dataBroker);
-
-        final NetconfNotificationOperationServiceFactory netconfNotificationOperationServiceFactory =
-            new NetconfNotificationOperationServiceFactory(getNotificationRegistryDependency()) {
-                @Override
-                public void close() {
-                    super.close();
-                    notificationToMdsalWriter.close();
-                    capabilityChangeListenerRegistration.close();
-                    sessionListenerRegistration.close();
-                    getAggregatorDependency().onRemoveNetconfOperationServiceFactory(this);
+        final WaitingServiceTracker<NetconfOperationServiceFactory> tracker =
+                WaitingServiceTracker.create(NetconfOperationServiceFactory.class, bundleContext, "(type=mdsal-netconf-notification)");
+        final NetconfOperationServiceFactory service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+        return Reflection.newProxy(AutoCloseableNetconfOperationServiceFactory.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);
                 }
-            };
+            }
+        });
+    }
 
-        getAggregatorDependency().onAddNetconfOperationServiceFactory(netconfNotificationOperationServiceFactory);
+    void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
 
-        return netconfNotificationOperationServiceFactory;
+    private static interface AutoCloseableNetconfOperationServiceFactory extends NetconfOperationServiceFactory, AutoCloseable {
     }
 }
index c87382cea19a4b608d61dc94a64ed69d44bec1d0..2ceb438e388e3162e107c803adec5cd3a72add38 100644 (file)
 */
 package org.opendaylight.controller.config.yang.netconf.mdsal.notification;
 
-public class NetconfMdsalNotificationMapperModuleFactory extends org.opendaylight.controller.config.yang.netconf.mdsal.notification.AbstractNetconfMdsalNotificationMapperModuleFactory {
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.osgi.framework.BundleContext;
 
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class NetconfMdsalNotificationMapperModuleFactory extends AbstractNetconfMdsalNotificationMapperModuleFactory {
+
+    @Override
+    public NetconfMdsalNotificationMapperModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+                                                                  NetconfMdsalNotificationMapperModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+        NetconfMdsalNotificationMapperModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule,
+                oldInstance, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+
+    @Override
+    public NetconfMdsalNotificationMapperModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+                                                      BundleContext bundleContext) {
+        NetconfMdsalNotificationMapperModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
 }
index 4a8c09ee24ee1ad9dd77a0e606598664dc0f099f..5ffe2c9ecddf383f51a37d44e4a141d5ceaac899 100644 (file)
@@ -15,8 +15,6 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
 import org.opendaylight.netconf.notifications.NotificationRegistration;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
@@ -32,16 +30,18 @@ import org.slf4j.LoggerFactory;
  * Listens on changes in netconf notification stream availability and writes
  * changes to the data store.
  */
-final class NotificationToMdsalWriter implements AutoCloseable, NetconfNotificationCollector.NetconfNotificationStreamListener, BindingAwareProvider {
+public final class NotificationToMdsalWriter implements AutoCloseable, NetconfNotificationCollector.NetconfNotificationStreamListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(NotificationToMdsalWriter.class);
 
     private final NetconfNotificationCollector netconfNotificationCollector;
+    private final DataBroker dataBroker;
     private NotificationRegistration notificationRegistration;
-    private DataBroker dataBroker;
 
-    public NotificationToMdsalWriter(NetconfNotificationCollector netconfNotificationCollector) {
+    public NotificationToMdsalWriter(final NetconfNotificationCollector netconfNotificationCollector,
+                                     final DataBroker dataBroker) {
         this.netconfNotificationCollector = netconfNotificationCollector;
+        this.dataBroker = dataBroker;
     }
 
     @Override
@@ -65,9 +65,10 @@ final class NotificationToMdsalWriter implements AutoCloseable, NetconfNotificat
         notificationRegistration.close();
     }
 
-    @Override
-    public void onSessionInitiated(BindingAwareBroker.ProviderContext session) {
-        dataBroker = session.getSALService(DataBroker.class);
+    /**
+     * Invoke by blueprint
+     */
+    public void start() {
         notificationRegistration = netconfNotificationCollector.registerStreamListener(this);
     }
 
index 54f67d39789233959e2b481723788bd2dc9699d3..f8d1b0edb6e7bb82f33f806daa419c1315fbe5f2 100644 (file)
@@ -10,9 +10,11 @@ package org.opendaylight.controller.config.yang.netconf.mdsal.notification;
 import com.google.common.base.Preconditions;
 import java.util.Collection;
 import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
+import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdOrZeroType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Sessions;
@@ -21,6 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.not
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionEndBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStartBuilder;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
@@ -31,11 +34,16 @@ public class SessionNotificationProducer extends OperationalDatastoreListener<Se
 
     private static final InstanceIdentifier<Session> SESSION_INSTANCE_IDENTIFIER =
             InstanceIdentifier.create(NetconfState.class).child(Sessions.class).child(Session.class);
+
     private final BaseNotificationPublisherRegistration baseNotificationPublisherRegistration;
+    private final ListenerRegistration sessionListenerRegistration;
 
-    public SessionNotificationProducer(BaseNotificationPublisherRegistration baseNotificationPublisherRegistration) {
+    public SessionNotificationProducer(final NetconfNotificationCollector netconfNotificationCollector,
+                                       final DataBroker dataBroker) {
         super(SESSION_INSTANCE_IDENTIFIER);
-        this.baseNotificationPublisherRegistration = baseNotificationPublisherRegistration;
+
+        this.baseNotificationPublisherRegistration = netconfNotificationCollector.registerBaseNotificationPublisher();
+        this.sessionListenerRegistration = registerOnChanges(dataBroker);
     }
 
     @Override
@@ -82,4 +90,16 @@ public class SessionNotificationProducer extends OperationalDatastoreListener<Se
         baseNotificationPublisherRegistration.onSessionEnded(sessionEnd);
     }
 
+
+    /**
+     * Invoke by blueprint
+     */
+    public void close() {
+        if (baseNotificationPublisherRegistration != null) {
+            baseNotificationPublisherRegistration.close();
+        }
+        if (sessionListenerRegistration != null) {
+            sessionListenerRegistration.close();
+        }
+    }
 }
index 7c82d640d73f51fe66a7db4014c8202daacbe9f7..41ae98e1a2822505f79cc314a11964784bcfa53d 100644 (file)
@@ -11,24 +11,24 @@ package org.opendaylight.netconf.mdsal.notification;
 import java.util.Collections;
 import java.util.Set;
 import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
+import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener;
 import org.opendaylight.netconf.notifications.NetconfNotificationRegistry;
 
 public class NetconfNotificationOperationServiceFactory implements NetconfOperationServiceFactory, AutoCloseable {
 
     private final NetconfNotificationRegistry netconfNotificationRegistry;
+    private final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener;
 
-    private static final AutoCloseable AUTO_CLOSEABLE = new AutoCloseable() {
-        @Override
-        public void close() throws Exception {
-            // NOOP
-        }
-    };
-
-    public NetconfNotificationOperationServiceFactory(NetconfNotificationRegistry netconfNotificationRegistry) {
+    public NetconfNotificationOperationServiceFactory(final NetconfNotificationRegistry netconfNotificationRegistry,
+                                                      final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener) {
         this.netconfNotificationRegistry = netconfNotificationRegistry;
+        this.netconfOperationServiceFactoryListener = netconfOperationServiceFactoryListener;
+
+        this.netconfOperationServiceFactoryListener.onAddNetconfOperationServiceFactory(this);
     }
 
     @Override
@@ -46,10 +46,11 @@ public class NetconfNotificationOperationServiceFactory implements NetconfOperat
 
     @Override
     public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
-        return AUTO_CLOSEABLE;
+        return NoopAutoCloseable.INSTANCE;
     }
 
     @Override
     public void close() {
+        this.netconfOperationServiceFactoryListener.onRemoveNetconfOperationServiceFactory(this);
     }
 }
diff --git a/netconf/mdsal-netconf-notification/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-notification.xml b/netconf/mdsal-netconf-notification/src/main/resources/org/opendaylight/blueprint/mdsal-netconf-notification.xml
new file mode 100755 (executable)
index 0000000..5550de8
--- /dev/null
@@ -0,0 +1,66 @@
+<?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">
+
+    <reference id="dataBroker"
+               interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+               odl:type="default"/>
+    <reference id="netconfOperationServiceFactoryListener"
+               interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener"
+               odl:type="mapper-aggregator-registry"/>
+
+    <!--This is the MD-SAL netconf server notification 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>
+    <service ref="netconfNotificationManager"
+             interface="org.opendaylight.netconf.notifications.NetconfNotificationCollector"
+             odl:type="netconf-notification-manager">
+    </service>
+
+    <bean id="notificationToMdsalWriter"
+          class="org.opendaylight.controller.config.yang.netconf.mdsal.notification.NotificationToMdsalWriter"
+          init-method="start"
+          destroy-method="close">
+        <argument ref="netconfNotificationManager"/>
+        <argument ref="dataBroker"/>
+    </bean>
+
+    <bean id="capabilityChangeNotificationProducer"
+          class="org.opendaylight.controller.config.yang.netconf.mdsal.notification.CapabilityChangeNotificationProducer"
+          destroy-method="close">
+        <argument ref="netconfNotificationManager"/>
+        <argument ref="dataBroker"/>
+    </bean>
+
+    <bean id="sessionNotificationProducer"
+          class="org.opendaylight.controller.config.yang.netconf.mdsal.notification.SessionNotificationProducer"
+          destroy-method="close">
+        <argument ref="netconfNotificationManager"/>
+        <argument ref="dataBroker"/>
+    </bean>
+
+    <bean id="netconfNotificationOperationServiceFactory"
+          class="org.opendaylight.netconf.mdsal.notification.NetconfNotificationOperationServiceFactory"
+          destroy-method="close">
+        <argument ref="netconfNotificationManager"/>
+        <argument ref="netconfOperationServiceFactoryListener"/>
+    </bean>
+    <service ref="netconfNotificationOperationServiceFactory"
+             interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory"
+             odl:type="mdsal-netconf-notification"/>
+</blueprint>
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
deleted file mode 100755 (executable)
index e21f07d..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?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 db4e8bee0f5f29b067a8fdcd4a18354ad4535224..956abf3353697125c3168d0ef019f5fb1932a777 100644 (file)
@@ -30,50 +30,6 @@ module netconf-mdsal-notification {
          case netconf-mdsal-notification-mapper {
              when "/config:modules/config:module/config:type = 'netconf-mdsal-notification-mapper'";
 
-             container aggregator {
-                 uses config:service-ref {
-                     refine type {
-                         mandatory true;
-                         config:required-identity nnm:netconf-mapper-registry;
-                         }
-                 }
-             }
-
-             container binding-aware-broker {
-                 uses config:service-ref {
-                     refine type {
-                         mandatory true;
-                         config:required-identity md-sal-binding:binding-broker-osgi-registry;
-                     }
-                 }
-             }
-
-             container data-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-async-data-broker;
-                    }
-                }
-             }
-
-             container notification-collector {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity nnn:netconf-notification-collector;
-                    }
-                }
-             }
-
-            container notification-registry {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity nnn:netconf-notification-registry;
-                    }
-                }
-            }
         }
     }
 }
\ No newline at end of file
index e2156413bcd178af85de108ff27ff84682940d60..2f9ae073c1818403f890d72d7762b7f863f756af 100644 (file)
@@ -23,9 +23,13 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
+import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities;
@@ -34,20 +38,35 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.not
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.ChangedByBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.changed.by.server.or.user.ServerBuilder;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class CapabilityChangeNotificationProducerTest {
 
+    private CapabilityChangeNotificationProducer capabilityChangeNotificationProducer;
+
     @Mock
     private BaseNotificationPublisherRegistration baseNotificationPublisherRegistration;
-    private CapabilityChangeNotificationProducer capabilityChangeNotificationProducer;
+    @Mock
+    private ListenerRegistration listenerRegistration;
+
+    @Mock
+    private NetconfNotificationCollector netconfNotificationCollector;
+    @Mock
+    private DataBroker dataBroker;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
+
+        doReturn(listenerRegistration).when(dataBroker).registerDataTreeChangeListener(any(DataTreeIdentifier.class), any(DataTreeChangeListener.class));
+
         doNothing().when(baseNotificationPublisherRegistration).onCapabilityChanged(any(NetconfCapabilityChange.class));
-        capabilityChangeNotificationProducer = new CapabilityChangeNotificationProducer(baseNotificationPublisherRegistration);
+
+        doReturn(baseNotificationPublisherRegistration).when(netconfNotificationCollector).registerBaseNotificationPublisher();
+
+        capabilityChangeNotificationProducer = new CapabilityChangeNotificationProducer(netconfNotificationCollector, dataBroker);
     }
 
     @Test
index 6084d92cca0a62952a1b2b9bbc19e06668f015d4..316d56c0d1f18b22010928ba501caadaaf5b4581 100644 (file)
@@ -61,8 +61,8 @@ public class NotificationToMdsalWriterTest {
         doReturn(Futures.immediateCheckedFuture(null)).when(tx).submit();
         doReturn(tx).when(dataBroker).newWriteOnlyTransaction();
 
-        writer = new NotificationToMdsalWriter(notificationCollector);
-        writer.onSessionInitiated(session);
+        writer = new NotificationToMdsalWriter(notificationCollector, dataBroker);
+        writer.start();
     }
 
     @Test
index 8e29ea79717c26da638bf19b9b82305d68f5fba2..cedebb4eeaca0fd97f22d416449b46bf62d80853 100644 (file)
@@ -21,28 +21,49 @@ import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
+import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.SessionBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionEnd;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.ZeroBasedCounter32;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 
 public class SessionNotificationProducerTest {
 
     private SessionNotificationProducer publisher;
+
     @Mock
     private BaseNotificationPublisherRegistration registration;
+    @Mock
+    private ListenerRegistration listenerRegistration;
+
+    @Mock
+    private NetconfNotificationCollector netconfNotificationCollector;
+    @Mock
+    private DataBroker dataBroker;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        publisher = new SessionNotificationProducer(registration);
+
+        doReturn(listenerRegistration).when(dataBroker).registerDataTreeChangeListener(any(DataTreeIdentifier.class), any(DataTreeChangeListener.class));
+
+        doNothing().when(registration).onCapabilityChanged(any(NetconfCapabilityChange.class));
         doNothing().when(registration).onSessionStarted(any());
         doNothing().when(registration).onSessionEnded(any());
+
+        doReturn(registration).when(netconfNotificationCollector).registerBaseNotificationPublisher();
+
+        publisher = new SessionNotificationProducer(netconfNotificationCollector, dataBroker);
     }
 
     @Test
index b6e0788ea95db996cc9cc99c10fb584648c80c04..c6f236a42f08847a5e216ec5faa1ff4d9fd4649a 100644 (file)
           <module>
               <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">prefix:netconf-mdsal-notification-mapper</type>
               <name>netconf-mdsal-notification-mapper</name>
-              <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">
-                  <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-aware-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">
-                  <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>
-              <aggregator xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper">prefix:netconf-mapper-registry</type>
-                  <name>mapper-aggregator-registry</name>
-              </aggregator>
-              <notification-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:netconf:mdsal:notification">
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification">prefix:netconf-notification-registry</type>
-                  <name>netconf-notification-manager</name>
-              </notification-registry>
-              <notification-collector>
-                  <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification">prefix:netconf-notification-collector</type>
-                  <name>netconf-notification-manager</name>
-              </notification-collector>
           </module>
 
           <module>
                     <provider>/modules/module[type='netconf-server-dispatcher-impl'][name='netconf-mdsal-server-dispatcher']</provider>
                 </instance>
             </service>
-            <service>
-                <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:north:mapper">prefix:netconf-northbound-mapper</type>
-                <instance>
-                    <name>netconf-mdsal-notification-mapper</name>
-                    <provider>/modules/module[type='netconf-mdsal-notification-mapper'][name='netconf-mdsal-notification-mapper']</provider>
-                </instance>
-            </service>
             <service>
                 <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netconf:northbound:notification">prefix:netconf-notification-collector</type>
                 <instance>