From 45ba914ceb09b9cd9000b9095dd31ec174b12f89 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Wed, 18 May 2022 08:34:39 +0800 Subject: [PATCH] Add dubbo thread pool adaptation module --- hippo4j-adapter/hippo4j-adapter-dubbo/pom.xml | 50 ++++++++++++++++++ .../adapter/dubbo/DubboThreadPoolAdapter.java | 52 +++++++++++++++++++ hippo4j-adapter/pom.xml | 1 + .../pom.xml | 50 ++++++++++++++++++ .../dubbo/DubboAdapterAutoConfiguration.java | 45 ++++++++++++++++ .../main/resources/META-INF/spring.factories | 1 + .../pom.xml | 1 + pom.xml | 6 +++ 8 files changed, 206 insertions(+) create mode 100644 hippo4j-adapter/hippo4j-adapter-dubbo/pom.xml create mode 100644 hippo4j-adapter/hippo4j-adapter-dubbo/src/main/java/cn/hippo4j/adapter/dubbo/DubboThreadPoolAdapter.java create mode 100644 hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-dubbo/pom.xml create mode 100644 hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-dubbo/src/main/java/cn/hippo4j/springboot/starter/adapter/dubbo/DubboAdapterAutoConfiguration.java create mode 100644 hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-dubbo/src/main/resources/META-INF/spring.factories diff --git a/hippo4j-adapter/hippo4j-adapter-dubbo/pom.xml b/hippo4j-adapter/hippo4j-adapter-dubbo/pom.xml new file mode 100644 index 00000000..d064872e --- /dev/null +++ b/hippo4j-adapter/hippo4j-adapter-dubbo/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + + cn.hippo4j + hippo4j-adapter + ${revision} + + hippo4j-adapter-dubbo + + + + cn.hippo4j + hippo4j-adapter-base + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + ${project.artifactId} + ${project.version} + ${maven.build.timestamp} + chen.ma + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.3 + + + + jar + + + + + + + diff --git a/hippo4j-adapter/hippo4j-adapter-dubbo/src/main/java/cn/hippo4j/adapter/dubbo/DubboThreadPoolAdapter.java b/hippo4j-adapter/hippo4j-adapter-dubbo/src/main/java/cn/hippo4j/adapter/dubbo/DubboThreadPoolAdapter.java new file mode 100644 index 00000000..a1863d27 --- /dev/null +++ b/hippo4j-adapter/hippo4j-adapter-dubbo/src/main/java/cn/hippo4j/adapter/dubbo/DubboThreadPoolAdapter.java @@ -0,0 +1,52 @@ +/* + * 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.adapter.dubbo; + +import cn.hippo4j.adapter.base.ThreadPoolAdapter; +import cn.hippo4j.adapter.base.ThreadPoolAdapterParameter; +import cn.hippo4j.adapter.base.ThreadPoolAdapterState; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.context.event.ApplicationStartedEvent; +import org.springframework.context.ApplicationListener; + +/** + * Dubbo thread-pool adapter. + */ +@Slf4j +public class DubboThreadPoolAdapter implements ThreadPoolAdapter, ApplicationListener { + + @Override + public String mark() { + return "Dubbo"; + } + + @Override + public ThreadPoolAdapterState getThreadPoolState(String identify) { + return null; + } + + @Override + public boolean updateThreadPool(ThreadPoolAdapterParameter threadPoolAdapterParameter) { + return false; + } + + @Override + public void onApplicationEvent(ApplicationStartedEvent event) { + + } +} diff --git a/hippo4j-adapter/pom.xml b/hippo4j-adapter/pom.xml index ddabe668..9d1c9d46 100644 --- a/hippo4j-adapter/pom.xml +++ b/hippo4j-adapter/pom.xml @@ -16,6 +16,7 @@ hippo4j-adapter-base + hippo4j-adapter-dubbo hippo4j-adapter-rocketmq hippo4j-adapter-spring-cloud-stream-rocketmq diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-dubbo/pom.xml b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-dubbo/pom.xml new file mode 100644 index 00000000..91221f2f --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-dubbo/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + + cn.hippo4j + hippo4j-spring-boot-starter-adapter + ${revision} + + hippo4j-spring-boot-starter-adapter-dubbo + + + + cn.hippo4j + hippo4j-adapter-rocketmq + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + ${project.artifactId} + ${project.version} + ${maven.build.timestamp} + chen.ma + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.3 + + + + jar + + + + + + + diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-dubbo/src/main/java/cn/hippo4j/springboot/starter/adapter/dubbo/DubboAdapterAutoConfiguration.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-dubbo/src/main/java/cn/hippo4j/springboot/starter/adapter/dubbo/DubboAdapterAutoConfiguration.java new file mode 100644 index 00000000..261493df --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-dubbo/src/main/java/cn/hippo4j/springboot/starter/adapter/dubbo/DubboAdapterAutoConfiguration.java @@ -0,0 +1,45 @@ +/* + * 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.dubbo; + +import cn.hippo4j.adapter.rocketmq.RocketMQThreadPoolAdapter; +import cn.hippo4j.common.config.ApplicationContextHolder; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Dubbo adapter auto configuration. + */ +@Configuration +public class DubboAdapterAutoConfiguration { + + @Bean + @ConditionalOnMissingBean + public ApplicationContextHolder simpleApplicationContextHolder() { + return new ApplicationContextHolder(); + } + + @Bean + @SuppressWarnings("all") + @ConditionalOnProperty(name = "dubbo.application.name") + public RocketMQThreadPoolAdapter rocketMQThreadPoolAdapter(ApplicationContextHolder applicationContextHolder) { + return new RocketMQThreadPoolAdapter(); + } +} diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-dubbo/src/main/resources/META-INF/spring.factories b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-dubbo/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..9f14bcd2 --- /dev/null +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/hippo4j-spring-boot-starter-adapter-dubbo/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.springboot.starter.adapter.dubbo.DubboAdapterAutoConfiguration diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/pom.xml b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/pom.xml index 80894806..3fae0bdd 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/pom.xml +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter-adapter/pom.xml @@ -14,6 +14,7 @@ hippo4j-spring-boot-starter-adapter-all + hippo4j-spring-boot-starter-adapter-dubbo hippo4j-spring-boot-starter-adapter-rocketmq hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq diff --git a/pom.xml b/pom.xml index 19a5c842..1dce2d7c 100644 --- a/pom.xml +++ b/pom.xml @@ -152,6 +152,12 @@ ${revision} + + cn.hippo4j + hippo4j-adapter-dubbo + ${revision} + + com.baomidou mybatis-plus-boot-starter