解决动态线程池配置为关闭时项目启动报错的问题 (#633)

* Register company information (#621)

* 登记公司

* Register company information

* Update official documentation

* Update powered-by.md (#623)

* hippo4j-config rename core to config (#627)

* feat: hippo4j-config rename core to config

* feat: hippo4j-config-example rename core to config

* feat: hippo4j-config-example rename core to config

* Code formatting

* Delete useless blank lines

* Add JSONUtilTest

* Update hippo4j-adapter.md (#629)

* Complete JSONUtilTest test cases (#628) (#630)

* load the web adapter project when the dynamic thread pool configuration enable is true

Co-authored-by: Lijx <lijinxingerm@gmail.com>
Co-authored-by: chen.ma <machencoding@163.com>
Co-authored-by: maxisvest <1447829379@qq.com>
Co-authored-by: BigXin0109 <1064730540@qq.com>
Co-authored-by: hbw1994 <transformme@126.com>
Co-authored-by: 黄成兴 <49221670+Createsequence@users.noreply.github.com>
Co-authored-by: shupeng.dou <shupeng.dou@ikang.com>
pull/639/head
Douspeng 2 years ago committed by GitHub
parent 2a88d910ab
commit 6c4ffa172d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.hippo4j.springboot.starter.adapter.web;
import org.springframework.context.annotation.Import;
import java.lang.annotation.*;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import(WebAdapterConfigurationSelector.class)
public @interface EnableWebAdapter {
}

@ -17,12 +17,13 @@
package cn.hippo4j.springboot.starter.adapter.web;
import cn.hippo4j.adapter.web.*;
import cn.hippo4j.adapter.web.WebThreadPoolHandlerChoose;
import cn.hippo4j.adapter.web.WebThreadPoolRunStateHandler;
import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler;
import cn.hippo4j.core.toolkit.inet.InetUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -32,11 +33,12 @@ import org.springframework.core.env.ConfigurableEnvironment;
* Web adapter auto configuration.
*/
@Configuration
@ConditionalOnBean(value = {InetUtils.class})
@Import({WebThreadPoolHandlerConfiguration.EmbeddedTomcat.class,
WebThreadPoolHandlerConfiguration.EmbeddedJetty.class,
WebThreadPoolHandlerConfiguration.EmbeddedUndertow.class})
@RequiredArgsConstructor
public class WebAdapterAutoConfiguration {
public class WebAdapterConfiguration {
private final ConfigurableEnvironment environment;

@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.hippo4j.springboot.starter.adapter.web;
import org.springframework.context.annotation.DeferredImportSelector;
import org.springframework.core.annotation.Order;
import org.springframework.core.type.AnnotationMetadata;
@Order
public class WebAdapterConfigurationSelector implements DeferredImportSelector {
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
return new String[]{WebAdapterConfiguration.class.getName()};
}
}

@ -1 +0,0 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.springboot.starter.adapter.web.WebAdapterAutoConfiguration

@ -35,6 +35,7 @@ import cn.hippo4j.message.config.MessageConfiguration;
import cn.hippo4j.message.service.AlarmControlHandler;
import cn.hippo4j.message.service.Hippo4jBaseSendMessageService;
import cn.hippo4j.message.service.Hippo4jSendMessageService;
import cn.hippo4j.springboot.starter.adapter.web.EnableWebAdapter;
import cn.hippo4j.springboot.starter.controller.ThreadPoolAdapterController;
import cn.hippo4j.springboot.starter.controller.WebThreadPoolController;
import cn.hippo4j.springboot.starter.controller.WebThreadPoolRunStateController;
@ -71,6 +72,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
@EnableConfigurationProperties(BootstrapProperties.class)
@ConditionalOnProperty(prefix = BootstrapProperties.PREFIX, value = "enable", matchIfMissing = true, havingValue = "true")
@ImportAutoConfiguration({HttpClientConfiguration.class, NettyClientConfiguration.class, DiscoveryConfiguration.class, MessageConfiguration.class, UtilAutoConfiguration.class})
@EnableWebAdapter
public class DynamicThreadPoolAutoConfiguration {
private final BootstrapProperties properties;

Loading…
Cancel
Save