Skip to content

springBoot 1.5.x适配Web容器线程池调整 #1106

Closed
@yanrongzhen

Description

@yanrongzhen

背景

在SpringBoot 1.5.x版本当中, 关于Web容器的获取和操作的api, 与SpringBoot 2.x版本(目前Hippo4j使用的主要版本)完全不兼容.
因此需要针对SpringBoot1.5.x版本做一个特定版本的实现, 以便可以操作web容器当中的线程池.

目标

通过类设计方法, 抽象和复用公共部分, 将具体针对特定版本的实现, 沉淀到下层各自版本模块当中.

实际行为

1.5x版本和2.x版本关于WEB容器的操作接口不兼容, cn.hippo4j.adapter.web.WebThreadPoolHandlerChoose.choose(WebThreadPoolHandlerChoose.java:38)
中获取实现类的时候报错.

image

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.hippo4j.adapter.web.WebThreadPoolService' available
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:352)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:339)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1094)
	at cn.hippo4j.common.config.ApplicationContextHolder.getBean(ApplicationContextHolder.java:47)
	**at cn.hippo4j.adapter.web.WebThreadPoolHandlerChoose.choose(WebThreadPoolHandlerChoose.java:38)**
	... 16 common frames omitted

解法

由于1.x已经开启一个定制化模块来进行适配(hippo4j-config-spring-boot-1x-starter), 将web容器的版本适配工作放在此模块当中.

其中, 类设计简化图示如下:

image

问题重现步骤

  1. 使用 SpringBoot 1.5.22.RELEASE版本
  2. 使用config模式, 配置tomcat/undertow/jetty 相关参数 (dynamic.thread-pool.tomcat/undertow/jetty.xxx

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions