X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Fosgi%2FConfigManagerActivator.java;h=7966b8983aab814ca310be6d660b5f8e1ba4fc1c;hp=828fcb01e11bb00a9fde10f064b93cc2cac34863;hb=f77ea78c351d1c3604287e8444aae6943f70042f;hpb=ee146664ac8ae45439c14a84fe769633c3ebf847 diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java index 828fcb01e1..7966b8983a 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java @@ -9,15 +9,16 @@ package org.opendaylight.controller.config.manager.impl.osgi; import static org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil.registerService; import static org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil.wrap; - import java.lang.management.ManagementFactory; import java.util.Arrays; import java.util.List; import javax.management.InstanceAlreadyExistsException; import javax.management.MBeanServer; +import org.opendaylight.controller.config.api.ConfigRegistry; import org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl; import org.opendaylight.controller.config.manager.impl.jmx.ConfigRegistryJMXRegistrator; -import org.opendaylight.controller.config.manager.impl.osgi.mapping.CodecRegistryProvider; +import org.opendaylight.controller.config.manager.impl.jmx.JMXNotifierConfigRegistry; +import org.opendaylight.controller.config.manager.impl.osgi.mapping.BindingContextProvider; import org.opendaylight.controller.config.manager.impl.osgi.mapping.ModuleInfoBundleTracker; import org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry; import org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil; @@ -27,61 +28,81 @@ import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedCon import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.util.tracker.ServiceTracker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ConfigManagerActivator implements BundleActivator { + + private static final Logger LOG = LoggerFactory.getLogger(ConfigManagerActivator.class); + private final MBeanServer configMBeanServer = ManagementFactory.getPlatformMBeanServer(); private AutoCloseable autoCloseable; @Override public void start(final BundleContext context) { - - ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();// the inner strategy is backed by thread context cl? - - RefreshingSCPModuleInfoRegistry moduleInfoRegistryWrapper = new RefreshingSCPModuleInfoRegistry( - moduleInfoBackedContext, moduleInfoBackedContext, context); - - ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker(moduleInfoRegistryWrapper); - - CodecRegistryProvider codecRegistryProvider = new CodecRegistryProvider(moduleInfoBackedContext, context); - - // start config registry - BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver = new BundleContextBackedModuleFactoriesResolver( - context); - ConfigRegistryImpl configRegistry = new ConfigRegistryImpl(bundleContextBackedModuleFactoriesResolver, configMBeanServer, - codecRegistryProvider.getCodecRegistry()); - - // track bundles containing factories - BlankTransactionServiceTracker blankTransactionServiceTracker = new BlankTransactionServiceTracker( - configRegistry); - ModuleFactoryBundleTracker primaryModuleFactoryBundleTracker = new ModuleFactoryBundleTracker( - blankTransactionServiceTracker); - - // start extensible tracker - ExtensibleBundleTracker bundleTracker = new ExtensibleBundleTracker<>(context, - primaryModuleFactoryBundleTracker, moduleInfoBundleTracker); - bundleTracker.open(); - - // register config registry to OSGi - AutoCloseable clsReg = registerService(context, moduleInfoBackedContext, GeneratedClassLoadingStrategy.class); - AutoCloseable configRegReg = registerService(context, configRegistry, ConfigRegistryImpl.class); - - // register config registry to jmx - ConfigRegistryJMXRegistrator configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(configMBeanServer); try { - configRegistryJMXRegistrator.registerToJMX(configRegistry); - } catch (InstanceAlreadyExistsException e) { - throw new IllegalStateException("Config Registry was already registered to JMX", e); + ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();// the inner strategy is backed by thread context cl? + + BindingContextProvider bindingContextProvider = new BindingContextProvider(); + + RefreshingSCPModuleInfoRegistry moduleInfoRegistryWrapper = new RefreshingSCPModuleInfoRegistry( + moduleInfoBackedContext, moduleInfoBackedContext, moduleInfoBackedContext, moduleInfoBackedContext, bindingContextProvider, context); + + ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker(moduleInfoRegistryWrapper); + + // start config registry + BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver = new BundleContextBackedModuleFactoriesResolver( + context); + ConfigRegistryImpl configRegistry = new ConfigRegistryImpl(bundleContextBackedModuleFactoriesResolver, configMBeanServer, + bindingContextProvider); + + // track bundles containing factories + BlankTransactionServiceTracker blankTransactionServiceTracker = new BlankTransactionServiceTracker( + configRegistry); + ModuleFactoryBundleTracker primaryModuleFactoryBundleTracker = new ModuleFactoryBundleTracker( + blankTransactionServiceTracker); + + // start extensible tracker + ExtensibleBundleTracker bundleTracker = new ExtensibleBundleTracker<>(context, + primaryModuleFactoryBundleTracker, moduleInfoBundleTracker); + bundleTracker.open(); + + // Wrap config registry with JMX notification publishing adapter + final JMXNotifierConfigRegistry notifyingConfigRegistry = + new JMXNotifierConfigRegistry(configRegistry, configMBeanServer); + + // register config registry to OSGi + AutoCloseable clsReg = registerService(context, moduleInfoBackedContext, GeneratedClassLoadingStrategy.class); + AutoCloseable configRegReg = registerService(context, notifyingConfigRegistry, ConfigRegistry.class); + + // register config registry to jmx + ConfigRegistryJMXRegistrator configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(configMBeanServer); + try { + configRegistryJMXRegistrator.registerToJMXNoNotifications(configRegistry); + } catch (InstanceAlreadyExistsException e) { + throw new IllegalStateException("Config Registry was already registered to JMX", e); + } + + // register config registry to jmx + final ConfigRegistryJMXRegistrator configRegistryJMXRegistratorWithNotifications = new ConfigRegistryJMXRegistrator(configMBeanServer); + try { + configRegistryJMXRegistrator.registerToJMX(notifyingConfigRegistry); + } catch (InstanceAlreadyExistsException e) { + throw new IllegalStateException("Config Registry was already registered to JMX", e); + } + + // TODO wire directly via moduleInfoBundleTracker + ServiceTracker serviceTracker = new ServiceTracker<>(context, ModuleFactory.class, + blankTransactionServiceTracker); + serviceTracker.open(); + + List list = Arrays.asList(bindingContextProvider, clsReg, configRegistry, wrap(bundleTracker), + configRegReg, configRegistryJMXRegistrator, configRegistryJMXRegistratorWithNotifications, wrap(serviceTracker), moduleInfoRegistryWrapper, notifyingConfigRegistry); + autoCloseable = OsgiRegistrationUtil.aggregate(list); + } catch(Exception e) { + LOG.warn("Error starting config manager", e); } - - // TODO wire directly via moduleInfoBundleTracker - ServiceTracker serviceTracker = new ServiceTracker<>(context, ModuleFactory.class, - blankTransactionServiceTracker); - serviceTracker.open(); - - List list = Arrays.asList( - codecRegistryProvider, clsReg,configRegistry, wrap(bundleTracker), configRegReg, configRegistryJMXRegistrator, wrap(serviceTracker)); - autoCloseable = OsgiRegistrationUtil.aggregate(list); } @Override