X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Fosgi%2FActivator.java;h=5642cc7188788fd74a7aeccf7ca8ffa97abd009e;hb=9070e358923aca6229137d46f9cae7ff458204dd;hp=83029c44e665ec77bc5796535353277fe481ea43;hpb=a92d9d6a21a0f6ca8d2153795721f500eaf29ee9;p=controller.git diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/Activator.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/Activator.java index 83029c44e6..5642cc7188 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/Activator.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/Activator.java @@ -25,7 +25,8 @@ public class Activator implements BundleActivator, YangStoreServiceTracker.YangS private static final Logger logger = LoggerFactory.getLogger(Activator.class); private BundleContext context; - ServiceRegistration osgiRegistration; + private ServiceRegistration osgiRegistration; + private ConfigRegistryLookupThread configRegistryLookup = null; @Override public void start(BundleContext context) throws Exception { @@ -36,20 +37,42 @@ public class Activator implements BundleActivator, YangStoreServiceTracker.YangS @Override public void stop(BundleContext context) throws Exception { + if (configRegistryLookup != null) { + configRegistryLookup.interrupt(); + } } @Override public synchronized void onYangStoreAdded(YangStoreService yangStoreService) { - checkState(osgiRegistration == null, "More than one onYangStoreAdded received"); - NetconfOperationServiceFactoryImpl factory = new NetconfOperationServiceFactoryImpl(yangStoreService); - logger.debug("Registering into OSGi"); - osgiRegistration = context.registerService(new String[]{NetconfOperationServiceFactory.class.getName()}, factory, - new Hashtable()); + checkState(configRegistryLookup == null, "More than one onYangStoreAdded received"); + configRegistryLookup = new ConfigRegistryLookupThread(yangStoreService); + configRegistryLookup.start(); } @Override public synchronized void onYangStoreRemoved() { - osgiRegistration.unregister(); + configRegistryLookup.interrupt(); + if (osgiRegistration != null) { + osgiRegistration.unregister(); + } osgiRegistration = null; + configRegistryLookup = null; + } + + private class ConfigRegistryLookupThread extends Thread { + private final YangStoreService yangStoreService; + + private ConfigRegistryLookupThread(YangStoreService yangStoreService) { + super("config-registry-lookup"); + this.yangStoreService = yangStoreService; + } + + @Override + public void run() { + NetconfOperationServiceFactoryImpl factory = new NetconfOperationServiceFactoryImpl(yangStoreService); + logger.debug("Registering into OSGi"); + osgiRegistration = context.registerService(new String[]{NetconfOperationServiceFactory.class.getName()}, factory, + new Hashtable()); + } } }