Use ObjectRegistration instead of Registration 74/5574/2
authorRobert Varga <rovarga@cisco.com>
Sun, 9 Mar 2014 18:48:01 +0000 (19:48 +0100)
committerRobert Varga <rovarga@cisco.com>
Mon, 10 Mar 2014 17:47:52 +0000 (18:47 +0100)
Registration is becoming a generic concept, not tied to a particular
object. ObjectRegistration succeeds it for uses where you need to a
getInstance() object to get the associated object back. Migrate to using
that to get rid of deprecation warnings.

Drive-by:
- fix raw type use of ServiceRegistration

Change-Id: Ieaf77ab25e5b284a39fa9a6da7b3b101eb3b9e46
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java

index 90131fe..c075b09 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.controller.config.manager.impl.jmx.ConfigRegistryJMXRegi
 import org.opendaylight.controller.config.manager.impl.osgi.mapping.ModuleInfoBundleTracker;
 import org.opendaylight.controller.config.manager.impl.osgi.mapping.RuntimeGeneratedMappingServiceActivator;
 import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
 import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
 import org.osgi.framework.BundleActivator;
@@ -31,13 +31,11 @@ import org.slf4j.LoggerFactory;
 public class ConfigManagerActivator implements BundleActivator {
     private static final Logger logger = LoggerFactory.getLogger(ConfigManagerActivator.class);
 
-    private ExtensibleBundleTracker<Collection<Registration<YangModuleInfo>>> bundleTracker;
+    private final MBeanServer configMBeanServer = ManagementFactory.getPlatformMBeanServer();
+    private ExtensibleBundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> bundleTracker;
     private ConfigRegistryImpl configRegistry;
     private ConfigRegistryJMXRegistrator configRegistryJMXRegistrator;
     private ServiceRegistration<?> configRegistryServiceRegistration;
-
-    private final MBeanServer configMBeanServer = ManagementFactory.getPlatformMBeanServer();
-
     private RuntimeGeneratedMappingServiceActivator mappingServiceActivator;
 
     @Override
index a8fdfda..7680f72 100644 (file)
@@ -7,8 +7,16 @@
  */
 package org.opendaylight.controller.config.manager.impl.osgi.mapping;
 
+import static java.lang.String.format;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
 import org.apache.commons.io.IOUtils;
-import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
 import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
 import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider;
@@ -19,39 +27,31 @@ import org.osgi.util.tracker.BundleTrackerCustomizer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-import static java.lang.String.format;
-
 /**
  * Tracks bundles and attempts to retrieve YangModuleInfo.
  */
-public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer<Collection<Registration<YangModuleInfo>>> {
+public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer<Collection<ObjectRegistration<YangModuleInfo>>> {
 
     private static final Logger logger = LoggerFactory.getLogger(ModuleInfoBundleTracker.class);
     public static final String GET_MODULE_INFO_METHOD = "getModuleInfo";
 
     public static final String MODULE_INFO_PROVIDER_PATH_PREFIX = "META-INF/services/";
 
-    private ModuleInfoBackedContext moduleInfoLoadingStrategy = ModuleInfoBackedContext.create();
+    private final ModuleInfoBackedContext moduleInfoLoadingStrategy = ModuleInfoBackedContext.create();
 
     public GeneratedClassLoadingStrategy getModuleInfoLoadingStrategy() {
         return moduleInfoLoadingStrategy;
     }
 
     @Override
-    public Collection<Registration<YangModuleInfo>> addingBundle(Bundle bundle, BundleEvent event) {
+    public Collection<ObjectRegistration<YangModuleInfo>> addingBundle(Bundle bundle, BundleEvent event) {
         URL resource = bundle.getEntry(MODULE_INFO_PROVIDER_PATH_PREFIX + YangModelBindingProvider.class.getName());
 
         if(resource==null) {
             return null;
         }
 
-        List<Registration<YangModuleInfo>> registrations = new LinkedList<>();
+        List<ObjectRegistration<YangModuleInfo>> registrations = new LinkedList<>();
 
         try (InputStream inputStream = resource.openStream()) {
             List<String> lines = IOUtils.readLines(inputStream);
@@ -70,17 +70,17 @@ public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer<Co
     }
 
     @Override
-    public void modifiedBundle(Bundle bundle, BundleEvent event, Collection<Registration<YangModuleInfo>> object) {
+    public void modifiedBundle(Bundle bundle, BundleEvent event, Collection<ObjectRegistration<YangModuleInfo>> object) {
         // NOOP
     }
 
     @Override
-    public void removedBundle(Bundle bundle, BundleEvent event, Collection<Registration<YangModuleInfo>> regs) {
+    public void removedBundle(Bundle bundle, BundleEvent event, Collection<ObjectRegistration<YangModuleInfo>> regs) {
         if(regs == null) {
             return;
         }
 
-        for (Registration<YangModuleInfo> reg : regs) {
+        for (ObjectRegistration<YangModuleInfo> reg : regs) {
             try {
                 reg.close();
             } catch (Exception e) {

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.