use of com.alipay.sofa.rpc.boot.runtime.param.RpcBindingParam in project sofa-boot by alipay.
the class TripleBindingConverter method convert.
@Override
public RpcBinding convert(SofaService sofaServiceAnnotation, SofaServiceBinding sofaServiceBindingAnnotation, BindingConverterContext bindingConverterContext) {
RpcBindingParam bindingParam = new TripleBindingParam();
convertServiceAnnotation(bindingParam, sofaServiceAnnotation, sofaServiceBindingAnnotation, bindingConverterContext);
return new TripleBinding(bindingParam, bindingConverterContext.getApplicationContext(), bindingConverterContext.isInBinding());
}
use of com.alipay.sofa.rpc.boot.runtime.param.RpcBindingParam in project sofa-boot by alipay.
the class MockBeanConfigTest method testEmptyMockBean.
@Test
public void testEmptyMockBean() {
RpcBindingParam rpcBindingParam = new BoltBindingParam();
RpcBinding rpcBinding = new BoltBinding(rpcBindingParam, null, true);
try {
consumerConfigHelper.getMockRef(rpcBinding, null);
Assert.fail();
} catch (IllegalArgumentException e) {
// success;
}
}
use of com.alipay.sofa.rpc.boot.runtime.param.RpcBindingParam in project sofa-boot by alipay.
the class BoltBindingConverter method convert.
@Override
public RpcBinding convert(SofaReference sofaReferenceAnnotation, SofaReferenceBinding sofaReferenceBindingAnnotation, BindingConverterContext bindingConverterContext) {
RpcBindingParam bindingParam = new BoltBindingParam();
convertReferenceAnnotation(bindingParam, sofaReferenceBindingAnnotation, bindingConverterContext);
return new BoltBinding(bindingParam, bindingConverterContext.getApplicationContext(), bindingConverterContext.isInBinding());
}
use of com.alipay.sofa.rpc.boot.runtime.param.RpcBindingParam in project sofa-boot by alipay.
the class DubboBindingConverter method convert.
@Override
public RpcBinding convert(SofaReference sofaReferenceAnnotation, SofaReferenceBinding sofaReferenceBindingAnnotation, BindingConverterContext bindingConverterContext) {
RpcBindingParam bindingParam = new DubboBindingParam();
convertReferenceAnnotation(bindingParam, sofaReferenceBindingAnnotation, bindingConverterContext);
return new DubboBinding(bindingParam, bindingConverterContext.getApplicationContext(), bindingConverterContext.isInBinding());
}
use of com.alipay.sofa.rpc.boot.runtime.param.RpcBindingParam in project sofa-boot by sofastack.
the class ProviderConfigHelper method getProviderConfig.
/**
* 获取 ProviderConfig
*
* @param contract the Contract
* @param binding the RpcBinding
* @param target 服务实例
* @return the ProviderConfig
* @throws SofaBootRpcRuntimeException
*/
public ProviderConfig getProviderConfig(Contract contract, RpcBinding binding, Object target) throws SofaBootRpcRuntimeException {
RpcBindingParam param = binding.getRpcBindingParam();
String id = binding.getBeanId();
String interfaceId = contract.getInterfaceType().getName();
Object ref = target;
String uniqueId = contract.getUniqueId();
Integer timeout = param.getTimeout();
Integer weight = param.getWeight();
Integer warmupTime = param.getWarmUpTime();
Integer warmupWeight = param.getWarmUpWeight();
UserThreadPool threadPool = param.getUserThreadPool();
String serialization = param.getSerialization();
List<Filter> filters = param.getFilters();
List<MethodConfig> methodConfigs = convertToMethodConfig(param.getMethodInfos());
ServerConfig serverConfig = serverConfigContainer.getServerConfig(binding.getBindingType().getType());
ProviderConfig providerConfig = new ProviderConfig();
if (StringUtils.hasText(appName)) {
providerConfig.setApplication(new ApplicationConfig().setAppName(appName));
}
if (StringUtils.hasText(id)) {
providerConfig.setId(id);
}
if (StringUtils.hasText(interfaceId)) {
providerConfig.setInterfaceId(interfaceId);
}
if (contract.getInterfaceType() != null) {
providerConfig.setProxyClass(contract.getInterfaceType());
}
if (ref != null) {
providerConfig.setRef(ref);
}
if (StringUtils.hasText(uniqueId)) {
providerConfig.setUniqueId(uniqueId);
}
if (timeout != null) {
providerConfig.setTimeout(timeout);
}
if (weight != null) {
providerConfig.setWeight(weight);
}
if (warmupTime != null) {
providerConfig.setParameter(ProviderInfoAttrs.ATTR_WARMUP_TIME, String.valueOf(warmupTime));
}
if (warmupWeight != null) {
providerConfig.setParameter(ProviderInfoAttrs.ATTR_WARMUP_WEIGHT, String.valueOf(warmupWeight));
}
if (!CollectionUtils.isEmpty(filters)) {
providerConfig.setFilterRef(filters);
}
if (!CollectionUtils.isEmpty(methodConfigs)) {
providerConfig.setMethods(methodConfigs);
}
if (threadPool != null) {
UserThreadPoolManager.registerUserThread(ConfigUniqueNameGenerator.getUniqueName(providerConfig), threadPool);
}
providerConfig.setServer(serverConfig);
String protocol = binding.getBindingType().getType();
// http protocol use default protocol
if (!SofaBootRpcConfigConstants.RPC_PROTOCOL_HTTP.equals(protocol)) {
providerConfig.setBootstrap(protocol);
}
if (StringUtils.hasText(serialization)) {
providerConfig.setSerialization(serialization);
}
if (param.getParameters() != null) {
providerConfig.setParameters(param.getParameters());
}
if (param.getRegistrys() != null && param.getRegistrys().size() > 0) {
List<String> registrys = param.getRegistrys();
for (String registryAlias : registrys) {
RegistryConfig registryConfig = registryConfigContainer.getRegistryConfig(registryAlias);
providerConfig.setRegistry(registryConfig);
}
} else if (registryConfigContainer.isMeshEnabled(protocol)) {
RegistryConfig registryConfig = registryConfigContainer.getRegistryConfig(SofaBootRpcConfigConstants.REGISTRY_PROTOCOL_MESH);
providerConfig.setRegistry(registryConfig);
} else {
RegistryConfig registryConfig = registryConfigContainer.getRegistryConfig();
providerConfig.setRegistry(registryConfig);
}
providerConfig.setRegister(false);
return providerConfig;
}
Aggregations