- extenderBundleTracker.close();
- } catch (Exception e) {
- logger.warn("Exception while closing extender", e);
- }
- try {
- configRegistryJMXRegistrator.close();
- } catch (Exception e) {
- logger.warn(
- "Exception while closing config registry jmx registrator",
- e);
- }
- try {
- configRegistryServiceRegistration.unregister();
- } catch (Exception e) {
- logger.warn("Exception while unregistering config registry", 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<ModuleFactory, Object> serviceTracker = new ServiceTracker<>(context, ModuleFactory.class,
+ blankTransactionServiceTracker);
+ serviceTracker.open();
+
+ List<AutoCloseable> 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);