Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/optimize auto configuration rpc #526

Merged
merged 2 commits into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,6 @@
*/
package com.alipay.sofa.boot.autoconfigure.rpc;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

import com.alipay.sofa.healthcheck.startup.ReadinessCheckCallback;
import com.alipay.sofa.rpc.boot.config.ConsulConfigurator;
import com.alipay.sofa.rpc.boot.config.FaultToleranceConfigurator;
Expand All @@ -53,6 +38,21 @@
import com.alipay.sofa.rpc.boot.runtime.adapter.helper.ConsumerConfigHelper;
import com.alipay.sofa.rpc.boot.runtime.adapter.helper.ProviderConfigHelper;
import com.alipay.sofa.rpc.boot.swagger.SwaggerServiceApplicationListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author <a href="mailto:lw111072@antfin.com">LiWei</a>
Expand All @@ -62,26 +62,31 @@
@ConditionalOnClass(SofaBootRpcProperties.class)
public class SofaRpcAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public ProviderConfigContainer providerConfigContainer() {
return new ProviderConfigContainer();
}

@Bean
@ConditionalOnMissingBean
public FaultToleranceConfigurator faultToleranceConfigurator() {
return new FaultToleranceConfigurator();
}

@Bean
@ConditionalOnMissingBean
public ServerConfigContainer serverConfigContainer(SofaBootRpcProperties sofaBootRpcProperties) {
return new ServerConfigContainer(sofaBootRpcProperties);
}

@Bean
@ConditionalOnMissingBean
public RegistryConfigContainer registryConfigContainer() {
return new RegistryConfigContainer();
}

@Bean
@ConditionalOnMissingBean
public ConsumerConfigHelper consumerConfigHelper(SofaBootRpcProperties sofaBootRpcProperties,
@Lazy RegistryConfigContainer registryConfigContainer,
@Value("${"
Expand All @@ -91,31 +96,37 @@ public ConsumerConfigHelper consumerConfigHelper(SofaBootRpcProperties sofaBootR
}

@Bean
@ConditionalOnMissingBean
public ProviderConfigHelper providerConfigHelper() {
return new ProviderConfigHelper();
}

@Bean
@ConditionalOnMissingBean
public ZookeeperConfigurator zookeeperConfigurator() {
return new ZookeeperConfigurator();
}

@Bean
@ConditionalOnMissingBean
public LocalFileConfigurator localFileConfigurator() {
return new LocalFileConfigurator();
}

@Bean
@ConditionalOnMissingBean
public MeshConfigurator meshConfigurator() {
return new MeshConfigurator();
}

@Bean
@ConditionalOnMissingBean
public RegistryConfigureProcessor nacosConfigurator() {
return new NacosConfigurator();
}

@Bean
@ConditionalOnMissingBean
public RegistryConfigureProcessor sofaRegistryConfigurator() {
return new SofaRegistryConfigurator();
}
Expand All @@ -130,16 +141,19 @@ public Map<String, RegistryConfigureProcessor> configureProcessorMap(List<Regist
}

@Bean
@ConditionalOnMissingBean
public RegistryConfigureProcessor consulConfigurator() {
return new ConsulConfigurator();
}

@Bean
@ConditionalOnMissingBean
public ConsumerConfigContainer consumerConfigContainer() {
return new ConsumerConfigContainer();
}

@Bean
@ConditionalOnMissingBean
public ApplicationContextClosedListener applicationContextClosedListener(ProviderConfigContainer providerConfigContainer,
ServerConfigContainer serverConfigContainer) {
return new ApplicationContextClosedListener(providerConfigContainer, serverConfigContainer);
Expand All @@ -153,6 +167,7 @@ public ApplicationContextRefreshedListener applicationContextRefreshedListener()
}

@Bean
@ConditionalOnMissingBean
public SofaBootRpcStartListener sofaBootRpcStartListener(ProviderConfigContainer providerConfigContainer,
FaultToleranceConfigurator faultToleranceConfigurator,
ServerConfigContainer serverConfigContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
*/
package com.alipay.sofa.rpc.boot.runtime.param;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.alipay.sofa.rpc.boot.runtime.binding.RpcBindingMethodInfo;
import com.alipay.sofa.rpc.filter.Filter;
import com.alipay.sofa.rpc.server.UserThreadPool;
import com.alipay.sofa.runtime.api.client.param.BindingParam;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* XML 元素和属性会被解析为 RpcBindingParam 。
*
Expand Down Expand Up @@ -79,6 +79,8 @@ public abstract class RpcBindingParam implements BindingParam {

protected List<String> registrys = new ArrayList<String>();

private Integer repeatReferLimit;

/**
* Getter method for property <tt>timeout</tt>.
*
Expand Down Expand Up @@ -534,4 +536,13 @@ public int hashCode() {
result = 31 * result + (registrys != null ? registrys.hashCode() : 0);
return result;
}

public Integer getRepeatReferLimit() {
return repeatReferLimit;
}

public void setRepeatReferLimit(Integer repeatReferLimit) {
this.repeatReferLimit = repeatReferLimit;
}

}