001/*
002 * Copyright 2012-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.web.reactive.context;
018
019import org.springframework.beans.factory.support.DefaultListableBeanFactory;
020import org.springframework.context.support.GenericApplicationContext;
021import org.springframework.core.env.ConfigurableEnvironment;
022import org.springframework.core.io.Resource;
023
024/**
025 * Subclass of {@link GenericApplicationContext}, suitable for reactive web environments.
026 *
027 * @author Stephane Nicoll
028 * @author Brian Clozel
029 * @since 2.0.0
030 */
031public class GenericReactiveWebApplicationContext extends GenericApplicationContext
032                implements ConfigurableReactiveWebApplicationContext {
033
034        /**
035         * Create a new {@link GenericReactiveWebApplicationContext}.
036         * @see #registerBeanDefinition
037         * @see #refresh
038         */
039        public GenericReactiveWebApplicationContext() {
040        }
041
042        /**
043         * Create a new {@link GenericReactiveWebApplicationContext} with the given
044         * DefaultListableBeanFactory.
045         * @param beanFactory the DefaultListableBeanFactory instance to use for this context
046         * @see #registerBeanDefinition
047         * @see #refresh
048         */
049        public GenericReactiveWebApplicationContext(DefaultListableBeanFactory beanFactory) {
050                super(beanFactory);
051        }
052
053        @Override
054        protected ConfigurableEnvironment createEnvironment() {
055                return new StandardReactiveWebEnvironment();
056        }
057
058        @Override
059        protected Resource getResourceByPath(String path) {
060                // We must be careful not to expose classpath resources
061                return new FilteredReactiveWebContextResource(path);
062        }
063
064}