All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.macrocloud.kernel.context.config.ContextAutoConfiguration Maven / Gradle / Ivy

package org.macrocloud.kernel.context.config;

import org.macrocloud.kernel.context.BaseContext;
import org.macrocloud.kernel.context.HttpHeadersGetter;
import org.macrocloud.kernel.context.ServletContext;
import org.macrocloud.kernel.context.ServletHttpHeadersGetter;
import org.macrocloud.kernel.context.props.BaseContextProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
 * 服务上下文配置
 */
@Configuration(proxyBeanMethods = false)
@Order(Ordered.HIGHEST_PRECEDENCE)
@EnableConfigurationProperties(BaseContextProperties.class)
public class ContextAutoConfiguration {

	@Bean
	@ConditionalOnMissingBean
	public HttpHeadersGetter baseHttpHeadersGetter(BaseContextProperties contextProperties) {
		return new ServletHttpHeadersGetter(contextProperties);
	}

	@Bean
	@ConditionalOnMissingBean
	public BaseContext baseContext(BaseContextProperties contextProperties, HttpHeadersGetter httpHeadersGetter) {
		return new ServletContext(contextProperties, httpHeadersGetter);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy