Class WebServiceConfiguration
java.lang.Object
cn.herodotus.engine.web.service.config.WebServiceConfiguration
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
@Configuration(proxyBeanMethods=false)
@EnableConfigurationProperties({EndpointProperties.class,PlatformProperties.class})
@Import({SpringdocConfiguration.class,SecureStampConfiguration.class})
public class WebServiceConfiguration
extends Object
implements org.springframework.context.ApplicationContextAware
Description: Web 服务通用配置
- Author:
- : gengwei.zheng
- Date:
- : 2024/1/24 16:34
-
Constructor Summary
ConstructorsConstructorDescriptionWebServiceConfiguration(PlatformProperties platformProperties, EndpointProperties endpointProperties, org.springframework.boot.autoconfigure.web.ServerProperties serverProperties) 尝试过几种 ServiceContextHolder 的初始化的方式,但都是会出现“时机”的不正确,导致 ServiceContextHolder 没有正常初始化,而导致抛错 1. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) cn.herodotus.engine.core.definition.function.ErrorCodeMapperBuilderCustomizerorg.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer
-
Constructor Details
-
WebServiceConfiguration
public WebServiceConfiguration(PlatformProperties platformProperties, EndpointProperties endpointProperties, org.springframework.boot.autoconfigure.web.ServerProperties serverProperties) 尝试过几种 ServiceContextHolder 的初始化的方式,但都是会出现“时机”的不正确,导致 ServiceContextHolder 没有正常初始化,而导致抛错 1. 利用 @AutoConfiguration 控制 Configuration 的前后顺序。这种方式始终会出现 WebSocket 先一步ServiceContextHolder初始化导致抛错。 2. 利用 @AutoConfigureOrder 指定 Configuration 顺序,也是同样问题。 3. 使用 Bean 的方式来构建 ServiceContextHolderBuilder,并且完成 ServiceContextHolder 的初始化的方式,始终不成功会出现时机不对的问题,导致抛错。跟踪过代码,发现使用 Bean 的方式,构建 ServiceContextHolderBuilder 根本就不执行。最终使用构造函数的方式,可以确保时机正确,几个参数对象设置正确,最终保证 ServiceContextHolder 的初始化时机合理
- Parameters:
platformProperties-PlatformPropertiesendpointProperties-EndpointPropertiesserverProperties-ServerProperties
-
-
Method Details
-
postConstruct
@PostConstruct public void postConstruct() -
setApplicationContext
public void setApplicationContext(@Nonnull org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
xssObjectMapperBuilderCustomizer
@Bean public org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer xssObjectMapperBuilderCustomizer() -
webErrorCodeMapperBuilderCustomizer
@Bean public cn.herodotus.engine.core.definition.function.ErrorCodeMapperBuilderCustomizer webErrorCodeMapperBuilderCustomizer()
-