Merge "Remove netconf-impl test resources"
[netconf.git] / netconf / netconf-notifications-impl / src / main / java / org / opendaylight / netconf / notifications / impl / osgi / Activator.java
index 1cbd5237389dad5900da775ce0458399ecb20721..967bd08914e17734628387badc80fe921e770be9 100644 (file)
@@ -14,8 +14,8 @@ import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.Set;
-import org.opendaylight.controller.config.util.capability.BasicCapability;
-import org.opendaylight.controller.config.util.capability.Capability;
+import org.opendaylight.netconf.api.capability.BasicCapability;
+import org.opendaylight.netconf.api.capability.Capability;
 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
 import org.opendaylight.netconf.api.util.NetconfConstants;
 import org.opendaylight.netconf.mapping.api.NetconfOperation;
@@ -41,16 +41,18 @@ public class Activator implements BundleActivator {
     private NetconfNotificationManager netconfNotificationManager;
 
     @Override
-    public void start(final BundleContext context) throws Exception {
+    public void start(final BundleContext context) {
         netconfNotificationManager = new NetconfNotificationManager();
         // Add properties to autowire with netconf-impl instance for cfg subsystem
         final Dictionary<String, String> props = new Hashtable<>();
         props.put(NetconfConstants.SERVICE_NAME, NetconfConstants.NETCONF_NOTIFICATION);
-        netconfNotificationCollectorServiceRegistration = context.registerService(NetconfNotificationCollector.class, netconfNotificationManager, new Hashtable<String, Object>());
+        netconfNotificationCollectorServiceRegistration = context.registerService(NetconfNotificationCollector.class,
+                netconfNotificationManager, new Hashtable<>());
 
         final NetconfOperationServiceFactory netconfOperationServiceFactory = new NetconfOperationServiceFactory() {
 
-            private final Set<Capability> capabilities = Collections.<Capability>singleton(new BasicCapability(NetconfNotification.NOTIFICATION_NAMESPACE));
+            private final Set<Capability> capabilities =
+                    Collections.singleton(new BasicCapability(NetconfNotification.NOTIFICATION_NAMESPACE));
 
             @Override
             public Set<Capability> getCapabilities() {
@@ -59,24 +61,20 @@ public class Activator implements BundleActivator {
 
             @Override
             public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
-                listener.onCapabilitiesChanged(capabilities, Collections.<Capability>emptySet());
-                return new AutoCloseable() {
-                    @Override
-                    public void close() {
-                        listener.onCapabilitiesChanged(Collections.<Capability>emptySet(), capabilities);
-                    }
-                };
+                listener.onCapabilitiesChanged(capabilities, Collections.emptySet());
+                return () -> listener.onCapabilitiesChanged(Collections.emptySet(), capabilities);
             }
 
             @Override
             public NetconfOperationService createService(final String netconfSessionIdForReporting) {
                 return new NetconfOperationService() {
 
-                    private final CreateSubscription createSubscription = new CreateSubscription(netconfSessionIdForReporting, netconfNotificationManager);
+                    private final CreateSubscription createSubscription =
+                            new CreateSubscription(netconfSessionIdForReporting, netconfNotificationManager);
 
                     @Override
                     public Set<NetconfOperation> getNetconfOperations() {
-                        return Sets.<NetconfOperation>newHashSet(
+                        return Sets.newHashSet(
                                 new Get(netconfSessionIdForReporting, netconfNotificationManager),
                                 createSubscription);
                     }
@@ -91,12 +89,13 @@ public class Activator implements BundleActivator {
 
         final Dictionary<String, String> properties = new Hashtable<>();
         properties.put(NetconfConstants.SERVICE_NAME, NetconfConstants.NETCONF_MONITORING);
-        operationaServiceRegistration = context.registerService(NetconfOperationServiceFactory.class, netconfOperationServiceFactory, properties);
+        operationaServiceRegistration = context.registerService(NetconfOperationServiceFactory.class,
+                netconfOperationServiceFactory, properties);
     }
 
     @Override
-    public void stop(final BundleContext context) throws Exception {
-        if(netconfNotificationCollectorServiceRegistration != null) {
+    public void stop(final BundleContext context) {
+        if (netconfNotificationCollectorServiceRegistration != null) {
             netconfNotificationCollectorServiceRegistration.unregister();
             netconfNotificationCollectorServiceRegistration = null;
         }