Skip to content

Commit

Permalink
*fix spi classloader
Browse files Browse the repository at this point in the history
Signed-off-by: provenceee <83857838+provenceee@users.noreply.github.com>
  • Loading branch information
provenceee committed Nov 18, 2024
1 parent 9c8d7e5 commit 85a7707
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>dubbo-2-6-integration-controller</artifactId>
<packaging>war</packaging>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down Expand Up @@ -62,6 +63,17 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.FilterType;
Expand All @@ -39,9 +41,13 @@
@ImportResource({"classpath:dubbo/consumer.xml"})
@ComponentScan(excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = {ProviderController.class,
ConsumerController.class, FlowController.class}))
public class ControllerApplication {
public class ControllerApplication extends SpringBootServletInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(ControllerApplication.class);

protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(ControllerApplication.class);
}

/**
* spring启动类
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

package io.sermant.flowcontrol.retry;

import io.sermant.core.plugin.Plugin;
import io.sermant.core.plugin.PluginManager;
import io.sermant.core.plugin.agent.entity.ExecuteContext;
import io.sermant.core.plugin.classloader.PluginClassLoader;
import io.sermant.core.utils.ClassUtils;
import io.sermant.flowcontrol.retry.cluster.AlibabaDubboCluster;
import io.sermant.flowcontrol.retry.cluster.AlibabaDubboClusterInvoker;
Expand Down Expand Up @@ -71,20 +74,22 @@ protected ExecuteContext doAfter(ExecuteContext context) {
}
final Optional<Class<?>> retryInvokerClass;
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
Plugin flowcontrol = PluginManager.getPluginMap().get("flowcontrol");
PluginClassLoader pluginClassLoader = flowcontrol.getPluginClassLoader();
if (APACHE_DUBBO_CLUSTER_CLASS_NAME.equals(type.getName())) {
ClassUtils.defineClass(
"io.sermant.flowcontrol.retry.cluster.ApacheDubboClusterInvoker", contextClassLoader,
contextClassLoader);
pluginClassLoader);
retryInvokerClass = ClassUtils.defineClass(
"io.sermant.flowcontrol.retry.cluster.ApacheDubboCluster", contextClassLoader,
contextClassLoader);
pluginClassLoader);
} else if (ALIBABA_DUBBO_CLUSTER_CLASS_NAME.equals(type.getName())) {
ClassUtils.defineClass(
"io.sermant.flowcontrol.retry.cluster.AlibabaDubboClusterInvoker", contextClassLoader,
contextClassLoader);
pluginClassLoader);
retryInvokerClass = ClassUtils.defineClass(
"io.sermant.flowcontrol.retry.cluster.AlibabaDubboCluster", contextClassLoader,
contextClassLoader);
pluginClassLoader);
} else {
return context;
}
Expand Down

0 comments on commit 85a7707

Please sign in to comment.