Binds the {@link ApplicationContext} to the current context class loader .
551293
public static void bind(ApplicationContext context) {
        Object old = contextMap.putIfAbsent(getContextClassLoader(), context);
        if (old != null) {
            throw new IllegalStateException(
                "There is already a ApplicationContext associated with the context ClassLoader of the current thread!");
        }
    }
1301210
@Override
    public void onApplicationEvent(@Nonnull ApplicationEvent event) {
        if (event instanceof ContextRefreshedEvent) {
            synchronized (this) {
                ApplicationContext applicationContext = ((ContextRefreshedEvent) event).getApplicationContext();
                setApplicationContext(new WebApplicationContextAdapter(applicationContext, this.servletConfig.getServletContext()));

                // Configure the MVC infrastructure
                configureMultipartResolver();
                configureExceptionResolvers();
                configureHandlerAdapters();
                registerCustomArgumentResolvers();
                configureHandlerMappings();
                addNebaViewResolver();

                // Picks up the previously registered MVC infrastructure
                onRefresh(applicationContext);

                this.initialized = true;
            }
        }
    }
488374
public static ImageLoader getLoader(Context context) {
        ImageLoader loader = (ImageLoader) context.getApplicationContext().getSystemService(IMAGE_LOADER_SERVICE);
        if (loader == null) {
            throw new IllegalStateException("ImageLoaderApplication not set as application class in" +
                    "AndroidManifest.xml");
        } else {
            return loader;
        }
    }
616488
public void init(ServletContext context) {
        if (profiles != null) {
            for (IDiagramProfile profile : profiles) {
                profile.init(context);
                _registry.put(profile.getName(),
                              profile);
            }
        }
    }
680245
@Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        if (StringUtils.isEmpty(propertyFile)) {
            return;
        }

        for (String pf : propertyFile.split("\\,")) {
            loadAliases(applicationContext, pf);
        }

        if (fileCount > 0) {
            log.info("Loaded " + entryCount + " aliases from " + fileCount + " files.");
        }
    }
912509
public void bind() throws Throwable
   {
      if (name == null)
         throw new IllegalArgumentException("Name is null");

      if (obj == null)
         throw new IllegalArgumentException("Obj is null");

      if (trace)
         log.trace("Binding " + obj.getClass().getName() + " under " + name);

      Properties properties = new Properties();
      properties.setProperty(Context.PROVIDER_URL, jndiProtocol + "://" + jndiHost + ":" + jndiPort);
      Context context = new InitialContext(properties);

      try
      {
         String className = obj.getClass().getName();
         Reference ref = new Reference(className,
                                       new StringRefAddr("class", className),
                                       JndiBinder.class.getName(),
                                       null);
         ref.add(new StringRefAddr("name", name));

         objs.put(name, obj);

         Util.bind(context, name, ref);

         if (log.isDebugEnabled())
            log.debug("Bound " + obj.getClass().getName() + " under " + name);
      }
      finally
      {
         if (context != null)
         {
            try
            {
               context.close();
            }
            catch (NamingException ne)
            {
               // Ignore
            }
         }
      }
   }
1049480
public void setContext( AdapterContext context )
    {
        Object servletContext = context.getExternalContext();
        assert servletContext instanceof ServletContext : servletContext;
        _servletContext = ( ServletContext ) servletContext;
        _eventReporter = createEventReporter();
    }
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();
	}
750995
public static ClassLoader getContextClassLoader(Class<?> contextClass) {
        return Objects.firstNonNull(
                Thread.currentThread().getContextClassLoader(),
                contextClass.getClassLoader()
        );
    }
378290
protected final void configureWebAppContext(WebAppContext context,
			ServletContextInitializer... initializers) {
		Assert.notNull(context, "Context must not be null");
		context.setTempDirectory(getTempDirectory());
		if (this.resourceLoader != null) {
			context.setClassLoader(this.resourceLoader.getClassLoader());
		}
		String contextPath = getContextPath();
		context.setContextPath(StringUtils.hasLength(contextPath) ? contextPath : "/");
		context.setDisplayName(getDisplayName());
		configureDocumentRoot(context);
		if (isRegisterDefaultServlet()) {
			addDefaultServlet(context);
		}
		if (shouldRegisterJspServlet()) {
			addJspServlet(context);
			context.addBean(new JasperInitializer(context), true);
		}
		addLocaleMappings(context);
		ServletContextInitializer[] initializersToUse = mergeInitializers(initializers);
		Configuration[] configurations = getWebAppContextConfigurations(context,
				initializersToUse);
		context.setConfigurations(configurations);
		context.setThrowUnavailableOnStartupException(true);
		configureSession(context);
		postProcessWebAppContext(context);
	}
517271
public static ContextLoaderListener createSpringContextLoader(final WebApplicationContext webApplicationContext) {
        return new ContextLoaderListener() {
            @SuppressWarnings("unchecked")
            @Override
            protected WebApplicationContext createWebApplicationContext(ServletContext sc) {
                return webApplicationContext;
            }
        };
    }
702144
public void bindWithApplication( String externalExportPrefix, String applicationName ) {

		Set<String> bounds = this.applicationBindings.get( externalExportPrefix );
		if( bounds == null ) {
			bounds = new LinkedHashSet<> ();
			this.applicationBindings.put( externalExportPrefix, bounds );
		}

		bounds.add( applicationName );
	}
417106
public AbstractEndpointBuilder<T> applicationContext(ApplicationContext applicationContext) {
        if (getEndpoint() instanceof ApplicationContextAware) {
            ((ApplicationContextAware) getEndpoint()).setApplicationContext(applicationContext);
        }

        if (getEndpoint() instanceof BeanFactoryAware) {
            ((BeanFactoryAware) getEndpoint()).setBeanFactory(applicationContext);
        }

        return this;
    }
585518
protected ApplicationContext initializeContext() {
        Function<Class<Object>, List<Object>> getBeans = this::getBeans;

        BeanFactory beanFactory = new BeanFactory(getBeans);
        InitContext context = new InitContext();

        AutoConfigurer.configureInitializers()
            .forEach(initializer -> initializer.init(context, beanFactory));

        List<AbstractReaderWriter> readersWriters = AutoConfigurer.configureReadersWriters();

        ExceptionHandlerInterceptor exceptionHandlerInterceptor = new ExceptionHandlerInterceptor();
        COMMON_INTERCEPTORS.add(exceptionHandlerInterceptor);
        Map<Boolean, List<Reader>> readers = createTransformers(
            concat(beanFactory.getAll(Reader.class), context.getReaders(), readersWriters));
        Map<Boolean, List<Writer>> writers = createTransformers(
            concat(beanFactory.getAll(Writer.class), context.getWriters(), readersWriters));
        List<Interceptor> interceptors = sort(
            concat(beanFactory.getAll(Interceptor.class), context.getInterceptors(), COMMON_INTERCEPTORS));
        List<ExceptionConfiguration> handlers =
            concat(beanFactory.getAll(ExceptionConfiguration.class), context.getExceptionConfigurations(), COMMON_HANDLERS);
        List<ControllerConfiguration> controllers =
            concat(beanFactory.getAll(ControllerConfiguration.class), context.getControllerConfigurations());

        orderDuplicationCheck(interceptors);

        Map<Class<? extends Exception>, InternalExceptionHandler> handlerMap =
            handlers.stream()
                .peek(ExceptionConfiguration::initialize)
                .flatMap(config -> config.getExceptionHandlers().stream())
                .peek(handler -> {
                    populateHandlerWriters(writers, handler, nonNull(handler.getResponseType()));
                    logExceptionHandler(handler);
                })
                .collect(toMap(InternalExceptionHandler::getExceptionClass, identity()));
        context.setExceptionHandlers(handlerMap);

        controllers.stream()
            .peek(ControllerConfiguration::initialize)
            .flatMap(config -> config.getRoutes().stream())
            .peek(route -> {
                route.interceptor(interceptors.toArray(new Interceptor[interceptors.size()]));
                populateRouteReaders(readers, route);
                populateRouteWriters(writers, route);
                logRoute(route);
            }).forEach(context::addRoute);

        ApplicationContextImpl applicationContext = new ApplicationContextImpl();
        applicationContext.setRoutes(context.getRoutes());
        applicationContext.setExceptionHandlers(context.getExceptionHandlers());

        exceptionHandlerInterceptor.setApplicationContext(applicationContext);
        return applicationContext;
    }
1321063
@Pure
	public static ClassLoader getContextClassLoader() throws AndroidException {
		synchronized (Android.class) {
			final ClassLoader cl = (contextClassLoader == null) ? null : contextClassLoader.get();
			if (cl != null) {
				return cl;
			}
		}
		final Object context = getContext();
		try {
			final Method method = context.getClass().getMethod("getClassLoader"); //$NON-NLS-1$
			final Object classLoader = method.invoke(context);
			final ClassLoader cl = (ClassLoader) classLoader;
			synchronized (Android.class) {
				contextClassLoader = new WeakReference<>(cl);
			}
			return cl;
		} catch (Exception e) {
			throw new AndroidException(e);
		}
	}
584517
@Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        propertyProvider = new PropertyProvider(applicationContext);
        conversionService = DefaultConversionService.getSharedInstance();
        wireParams(this);
        afterInitialized();
    }
828277
public static void loadApplicationBindings( Application app ) {

		File descDir = new File( app.getDirectory(), Constants.PROJECT_DIR_DESC );
		File appBindingsFile = new File( descDir, APP_BINDINGS_FILE );

		Logger logger = Logger.getLogger( ConfigurationUtils.class.getName());
		Properties props = Utils.readPropertiesFileQuietly( appBindingsFile, logger );
		for( Map.Entry<?,?> entry : props.entrySet()) {
			for( String part : Utils.splitNicely((String) entry.getValue(), "," )) {
				if( ! Utils.isEmptyOrWhitespaces( part ))
					app.bindWithApplication((String) entry.getKey(), part );
			}
		}
	}