Load beans into the application context.
@param context the context to load beans into
@param sources the sources to load
973932
protected void load(ApplicationContext context, Object[] sources) {
		if (logger.isDebugEnabled()) {
			logger.debug(
					"Loading source " + StringUtils.arrayToCommaDelimitedString(sources));
		}
		BeanDefinitionLoader loader = createBeanDefinitionLoader(
				getBeanDefinitionRegistry(context), sources);
		if (this.beanNameGenerator != null) {
			loader.setBeanNameGenerator(this.beanNameGenerator);
		}
		if (this.resourceLoader != null) {
			loader.setResourceLoader(this.resourceLoader);
		}
		if (this.environment != null) {
			loader.setEnvironment(this.environment);
		}
		loader.load();
	}
144845
public function initializeContext(Context $context)
    {
        if ($context instanceof ResourceContext) {
            $reflector = new ReflectionClass(get_class($context));

            if ($this->builder->getLoader() instanceof FileResourceLoader) {
                if ($this->builder->getLoader()->getBasePath() == null) {
                    $this->builder->getLoader()->setBasePath(dirname($reflector->getFileName()));
                }
            }

            if ($context->getResourceFactory()) {
                $this->builder->setFactory($context->getResourceFactory());
            }

            $context->setResourceBuilder($this->builder);
        }
    }
440266
protected void setupClasspathJarResourceIfNeeds(WebAppContext context) {
        if (isWarableWorld() || !isValidMetaInfConfiguration()) {
            return;
        }
        // may be local development and uses meta-inf configuration here
        final List<String> classpathList = extractJarClassspathList();
        for (String classpath : classpathList) {
            final String jarPath = convertClasspathToJarPath(classpath);
            final URL url;
            try {
                url = new URL(jarPath);
            } catch (MalformedURLException e) {
                throw new IllegalStateException("Failed to create URL from the jar path: " + jarPath, e);
            }
            context.getMetaData().addContainerResource(new JarResource(url) {
            });
        }
    }
1002814
private synchronized void addSourceMapSourceFiles(SourceMapInput inputSourceMap) {
    // synchronized annotation guards concurrent access to sourceMap during parsing.
    SourceMapConsumerV3 consumer = inputSourceMap.getSourceMap(errorManager);
    if (consumer == null) {
      return;
    }
    Collection<String> sourcesContent = consumer.getOriginalSourcesContent();
    if (sourcesContent == null) {
      return;
    }
    Iterator<String> content = sourcesContent.iterator();
    Iterator<String> sources = consumer.getOriginalSources().iterator();
    while (sources.hasNext() && content.hasNext()) {
      String code = content.next();
      SourceFile source = SourceMapResolver.getRelativePath(
          inputSourceMap.getOriginalPath(), sources.next());
      if (source != null) {
        sourceMap.addSourceFile(source.getOriginalPath(), code);
      }
    }
    if (sources.hasNext() || content.hasNext()) {
      throw new RuntimeException(
          "Source map's \"sources\" and \"sourcesContent\" lengths do not match.");
    }
  }
560046
public static void injectContextProxiesAndApplication(AbstractResourceInfo cri,
                                                          Object instance,
                                                          Application app,
                                                          ProviderFactory factory) {

        /** inject proxy for singleton only */
        if (!cri.isSingleton())
            return;

        /** application inject has been done earlier. @see LibertyJaxRsServerFactoryBean.injectContextApplication() */
        if (cri instanceof ApplicationInfo)
            return;

        JaxRsFactoryBeanCustomizer beanCustomizer = InjectionRuntimeContextHelper.findBeanCustomizer(instance.getClass(), cri.getBus());
        Boolean isManagedBean = beanCustomizer == null ? false : true;

        InjectionRuntimeContext irc = InjectionRuntimeContextHelper.getRuntimeContext();
        synchronized (instance) {
            for (Map.Entry<Class<?>, Method> entry : cri.getContextMethods().entrySet()) {
                Method method = entry.getValue();
                Object value = null;
                Class<?> cls = method.getParameterTypes()[0];
                if (cls == Application.class) {
                  value = app;
                } else if (VALUE_CONTEXTS.contains(cls.getName()) && factory != null) {
                    ContextProvider<?> p = factory.createContextProvider(cls, null);
                    if (p != null) {
                        value = p.createContext(null);
                    }
                } else {
                    value = cri.getContextSetterProxy(method);
                }

                if (isManagedBean)
                    irc.setRuntimeCtxObject(entry.getKey().getName(), value);
                else
                    InjectionUtils.injectThroughMethod(instance, method, value);
            }

            for (Field f : cri.getContextFields()) {
                Object value = null;
                Class<?> cls = f.getType();
                if (cls == Application.class) {
                    value = app;
                } else if (VALUE_CONTEXTS.contains(cls.getName()) && factory != null) {
                    ContextProvider<?> p = factory.createContextProvider(cls, null);
                    if (p != null) {
                        value = p.createContext(null);
                    }
                } else {
                    value = cri.getContextFieldProxy(f);
                }

                if (isManagedBean)
                    irc.setRuntimeCtxObject(f.getType().getName(), value);
                else
                    InjectionUtils.injectFieldValue(f, instance, value);
            }
        }

        Object o = null;
        //replace singleton resource after context injection is done.
        if (isManagedBean && (cri instanceof ClassResourceInfo)) {
            o = beanCustomizer.onSingletonServiceInit(instance,
                                                      InjectionRuntimeContextHelper.getBeanCustomizerContext(beanCustomizer, cri.getBus()));

            SingletonResourceProvider sp = new SingletonResourceProvider(o);
            ((ClassResourceInfo) cri).setResourceProvider(sp);
            instance = o;
        }

        if (!isManagedBean && (cri instanceof ClassResourceInfo))
        {
            //call postConstruct method for singleton resource which are non-CDI/EJB
            Method postConstructMethod = ResourceUtils.findPostConstructMethod(instance.getClass());
            InjectionUtils.invokeLifeCycleMethod(instance, postConstructMethod);
        }

    }
486152
public void createUISharedContext(Context context) {
		if (session != null) {
			uiContexts.put(context.getIndex(), context.duplicate());
		}
	}
574273
public void pushContexts(BeanO beanO) throws CSIException {
        // Push the callback BeanO first since this is fallible.
        pushCallbackBeanO(beanO);

        // Pushing ComponentMetaData and ClassLoader are infallible.
        BeanMetaData bmd = beanO.home.beanMetaData;
        pushMetaDataContexts(bmd);
    }
194182
public void afterPropertiesSet() {

		ApplicationContext context = this.context;

		if (context == null) {
			throw new IllegalStateException("ApplicationContext not set!");
		}

		Class<?> type = this.type;

		if (type == null) {
			throw new IllegalStateException("No type configured!");
		}

		this.targetSource = new BeansOfTypeTargetSource(context, type, false, exclusions);
	}
968296
protected void setContext(Context context) throws CpoException {
    try {
      if (context == null) {
        context_ = new InitialContext();
      } else {
        context_ = context;
      }
    } catch (NamingException e) {
      throw new CpoException("Error setting Context", e);
    }
  }
1103196
public void setContext(Context context) {
        log = Log.instance(context);
        options = Options.instance(context);
        classLoaderClass = options.get("procloader");
        locations.update(log, options, Lint.instance(context), FSInfo.instance(context));
    }
581711
public static void injectContextProxies(AbstractResourceInfo cri, Object instance) {
        injectContextProxiesAndApplication(cri, instance, null, null);
    }
1322890
@Override
    public void setApplicationContext(ApplicationContext appContext) throws BeansException {
        if (this.appContext != null) {
            throw new ApplicationContextException("Attempt to reinitialize application context.");
        }
        
        this.appContext = appContext;
    }
379701
private void initMessageSource() {
        if (contextBeanRegistry.containsBean(MESSAGE_SOURCE_BEAN_ID)) {
            messageSource = contextBeanRegistry.getBean(MESSAGE_SOURCE_BEAN_ID, MessageSource.class);
            if (log.isDebugEnabled()) {
                log.debug("Using MessageSource [" + messageSource + "]");
            }
        } else {
            // Use empty MessageSource to be able to accept getMessage calls.
            messageSource = new DelegatingMessageSource();
            if (log.isDebugEnabled()) {
                log.debug("Unable to locate MessageSource with name '" + MESSAGE_SOURCE_BEAN_ID +
                        "': using default [" + messageSource + "]");
            }
        }
    }
490769
public void loadPlugins() throws PluginException {
        if (initialised) {
            return;
        }

        ClassLoader gcl = application.getClassLoader();

        attemptLoadPlugins(gcl);

        if (!delayedLoadPlugins.isEmpty()) {
            loadDelayedPlugins();
        }
        if (!delayedEvictions.isEmpty()) {
            processDelayedEvictions();
        }

        pluginList = sortPlugins(pluginList);
        initializePlugins();
        initialised = true;
    }
467352
public static void init(ExternalContext context)
    {
        WebXmlParser parser = new WebXmlParser(context);
        WebXml webXml = parser.parse();
        context.getApplicationMap().put(WEB_XML_ATTR, webXml);
        MyfacesConfig mfconfig = MyfacesConfig.getCurrentInstance(context);
        long configRefreshPeriod = mfconfig.getConfigRefreshPeriod();
        webXml.setParsingTime(System.currentTimeMillis());
        webXml.setDelegateFacesServlet(mfconfig.getDelegateFacesServlet());
        refreshPeriod = (configRefreshPeriod * 1000);
    }
1363523
public EventBuilder withContexts(Map<String, Map<String, Object>> contexts) {
        event.setContexts(contexts);
        return this;
    }
1049480
public void setContext( AdapterContext context )
    {
        Object servletContext = context.getExternalContext();
        assert servletContext instanceof ServletContext : servletContext;
        _servletContext = ( ServletContext ) servletContext;
        _eventReporter = createEventReporter();
    }