Delayed registration of the platform MBeanServerPipeline in the OSGi registry.

@param systemContext The framework system bundle context
501217
private void preRegisterMBeanServerPipelineService(final BundleContext systemContext) {
        PlatformMBeanServerBuilder.addPlatformMBeanServerBuilderListener(new PlatformMBeanServerBuilderListener() {
            @Override
            @FFDCIgnore(IllegalStateException.class)
            public void platformMBeanServerCreated(final MBeanServerPipeline pipeline) {
                if (pipeline != null) {
                    final Hashtable<String, String> svcProps = new Hashtable<String, String>();
                    try {
                        AccessController.doPrivileged(new PrivilegedAction<Void>() {
                            @Override
                            public Void run() {
                                systemContext.registerService(MBeanServerPipeline.class.getName(), pipeline, svcProps);
                                return null;
                            }
                        });
                    } catch (IllegalStateException ise) { /* This instance of the system bundle is no longer valid. Ignore it. */
                    }
                }
            }
        });
    }
1237045
public Signal register(TimerContext context)
    {
        assert context != null;
        RegisteredSignal signal = new TimedSignal(context);
        queue.add(signal);
        return signal;
    }
902262
protected void activate(ComponentContext context) throws Exception {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(this, tc, "Activating");
        }

        processConfig(context.getProperties());

        SystemLogger.setLogService(logService);
    }
150973
@SuppressWarnings("unchecked")
    void initThreadContext(WSContextService contextSvc, Map<String, String> execProps) {
        threadContext = contextSvc.captureThreadContext(execProps);
    }
369249
public static void initialize(
      Context context,
      @Nullable ImagePipelineConfig imagePipelineConfig) {
    initialize(context, imagePipelineConfig, null);
  }
974155
protected synchronized void deactivate(ComponentContext context) {
        cfwBundleRef.deactivate(context);
        scheduledExecSvcRef.deactivate(context);
        injectionServiceSRRef.deactivate(context);
        injectionService12SRRef.deactivate(context);
        executorServiceRef.deactivate(context);
        injectionEngineSRRef.deactivate(context);
    }
531144
@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		try {
			HashSet<Class<?>> registeredTypes = new HashSet<>();

			// Get Service Broker
			ServiceBroker broker = applicationContext.getBean(ServiceBroker.class);

			// Find Services in Spring Application Context
			Map<String, Service> serviceMap = applicationContext.getBeansOfType(Service.class);
			if (serviceMap != null && !serviceMap.isEmpty()) {
				String name;
				for (Map.Entry<String, Service> service : serviceMap.entrySet()) {

					// Register Service in Broker
					name = service.getKey();
					registeredTypes.add(service.getClass());
					if (name != null && name.startsWith("$")) {
						broker.createService(name, service.getValue());
						logger.info("Service \"" + name + "\" registered.");
					} else {
						Service instance = service.getValue();
						broker.createService(instance);
						logger.info("Service \"" + instance.getName() + "\" registered.");
					}
				}
			}

			// Add new Services
			if (packagesToScan != null && packagesToScan.length > 0) {
				DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) applicationContext
						.getAutowireCapableBeanFactory();
				for (String packageName : packagesToScan) {
					if (!packageName.isEmpty()) {
						LinkedList<String> classNames = scan(packageName);
						for (String className : classNames) {
							if (className.indexOf('$') > -1) {
								continue;
							}
							className = packageName + '.' + className;
							Class<?> type = Class.forName(className);
							if (Service.class.isAssignableFrom(type)) {

								// Check type
								if (!registeredTypes.add(type)) {
									continue;
								}

								// Register Service in Spring
								String name = nameOf(type, false);
								BeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(type)
										.setScope(BeanDefinition.SCOPE_SINGLETON)
										.setAutowireMode(DefaultListableBeanFactory.AUTOWIRE_BY_TYPE).setLazyInit(false)
										.getBeanDefinition();
								beanFactory.registerBeanDefinition(name, definition);
								Service service = (Service) beanFactory.createBean(type);

								// Register Service in Broker
								broker.createService(service);

								// Log
								logger.info("Service \"" + name + "\" registered.");
							}
						}
					}
				}
			}
		} catch (Exception cause) {
			throw new FatalBeanException("Unable to define Moleculer Service!", cause);
		}
	}
1345327
public void registerProcessEngine(ProcessEngine processEngine) {

    if(processEngine == null) {
      throw new ProcessEngineException("Cannot register process engine with Msc Runtime Container: process engine is 'null'");
    }

    ServiceName serviceName = ServiceNames.forManagedProcessEngine(processEngine.getName());

    if(serviceContainer.getService(serviceName) == null) {
      MscManagedProcessEngine processEngineRegistration = new MscManagedProcessEngine(processEngine);

      // install the service asynchronously.
      childTarget.addService(serviceName, processEngineRegistration)
        .setInitialMode(Mode.ACTIVE)
        .addDependency(ServiceNames.forMscRuntimeContainerDelegate(), MscRuntimeContainerDelegate.class, processEngineRegistration.getRuntimeContainerDelegateInjector())
        .install();
    }

  }
260392
@Trivial
    protected void activate(ComponentContext componentContext) {
        Dictionary<String, ?> properties = componentContext.getProperties();
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(this, tc, "activate", properties);

        contextSvcRef.activate(componentContext);

        String jndiName = (String) properties.get(JNDI_NAME);
        name = jndiName == null ? (String) properties.get(CONFIG_ID) : jndiName;

        defaultExecutionProperties = new TreeMap<String, String>();
        defaultExecutionProperties.put(WSContextService.DEFAULT_CONTEXT, WSContextService.UNCONFIGURED_CONTEXT_TYPES);
        defaultExecutionProperties.put(WSContextService.TASK_OWNER, name);

        createDaemonThreads = (Boolean) properties.get(CREATE_DAEMON_THREADS);
        defaultPriority = (Integer) properties.get(DEFAULT_PRIORITY);
        Integer maxPriority = (Integer) properties.get(MAX_PRIORITY);
        threadGroup = AccessController.doPrivileged(new CreateThreadGroupAction(name + " Thread Group", maxPriority), threadGroupTracker.serverAccessControlContext);

        if (trace && tc.isEntryEnabled())
            Tr.exit(this, tc, "activate");
    }
976374
public void setSystemPropertyName (@Nullable final String systemPropertyName)
  {
    m_sSystemPropertyName = systemPropertyName == null ? SYSTEM_PROPERTY : systemPropertyName.trim ();
  }
1096193
private void register( final Bundle bundle )
    {
        LOG.debug( "Scanning bundle [" + bundle.getSymbolicName() + "]" );
        final List<T> resources = m_scanner.scan( bundle );
        m_mappings.put( bundle, resources );
        if( resources != null && resources.size() > 0 )
        {
            LOG.debug( "Found resources " + resources );
		            for( final BundleObserver<T> observer : m_observers )
		            {
		                try
		                {
		                	//here the executor service completes the job in an extra thread. 
		                	executorService.submit(new Runnable() {
		                		public void run() {
		                		    try 
		                		    {
		                		        observer.addingEntries( bundle, Collections.unmodifiableList( resources ) );
		                		    }
		                		    catch (Throwable t)
		                		    {
		                		        LOG.error( "Exception in executor thread", t );
		                		    }
		                		}
		                	});
		                }
		                catch( Throwable ignore )
		                {
		                    LOG.error( "Ignored exception during register", ignore );
		                }
		            }
        }
    }
281572
public static void register(PageContext pc) {// print.ds(Thread.currentThread().getName());
	if (pc == null) return; // TODO happens with Gateway, but should not!
	// TODO should i set the old one by "release"?
	Thread t = Thread.currentThread();
	t.setContextClassLoader(((ConfigImpl) pc.getConfig()).getClassLoaderEnv());
	((PageContextImpl) pc).setThread(t);
	pcThreadLocal.set(pc);
    }
955421
protected void postProcessApplicationContext(ConfigurableApplicationContext context) {
		if (this.beanNameGenerator != null) {
			context.getBeanFactory().registerSingleton(
					AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR,
					this.beanNameGenerator);
		}
		if (this.resourceLoader != null) {
			if (context instanceof GenericApplicationContext) {
				((GenericApplicationContext) context)
						.setResourceLoader(this.resourceLoader);
			}
			if (context instanceof DefaultResourceLoader) {
				((DefaultResourceLoader) context)
						.setClassLoader(this.resourceLoader.getClassLoader());
			}
		}
		if (this.addConversionService) {
			context.getBeanFactory().setConversionService(
					ApplicationConversionService.getSharedInstance());
		}
	}
718728
public static synchronized void initialize(Context context) {
    if (FrescoSystrace.isTracing()) {
      FrescoSystrace.beginSection("ImagePipelineFactory#initialize");
    }
    initialize(ImagePipelineConfig.newBuilder(context).build());
    if (FrescoSystrace.isTracing()) {
      FrescoSystrace.endSection();
    }
  }
741676
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
        final ResourceRoot deploymentRoot = phaseContext.getDeploymentUnit().getAttachment(Attachments.DEPLOYMENT_ROOT);
        final ModuleSpecification moduleSpecification = phaseContext.getDeploymentUnit().getAttachment(
                Attachments.MODULE_SPECIFICATION);
        if(deploymentRoot == null)
            return;
        final ServicesAttachment servicesAttachments = phaseContext.getDeploymentUnit().getAttachment(Attachments.SERVICES);
        if(servicesAttachments != null && !servicesAttachments.getServiceImplementations(ServiceActivator.class.getName()).isEmpty()) {
            moduleSpecification.addSystemDependency(MSC_DEP);
        }
    }
1055644
PlatformControl bind(ServicePlatform p, XmlWebApplicationContext c, ClassLoader l) {
        _platform = p;
        _root = c;
        _cloader = l;
        return this;
    }
406402
public static RequiredConfigurationHolder populateHostResolutionContext(final HostInfo hostInfo, final Resource root, final ExtensionRegistry extensionRegistry) {
        final RequiredConfigurationHolder rc = new RequiredConfigurationHolder();
        for (IgnoredNonAffectedServerGroupsUtil.ServerConfigInfo info : hostInfo.getServerConfigInfos()) {
            processServerConfig(root, rc, info, extensionRegistry);
        }
        return rc;
    }