Search in sources :

Example 21 with RpcBindingParam

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());
}
Also used : TripleBinding(com.alipay.sofa.rpc.boot.runtime.binding.TripleBinding) TripleBindingParam(com.alipay.sofa.rpc.boot.runtime.param.TripleBindingParam) RpcBindingParam(com.alipay.sofa.rpc.boot.runtime.param.RpcBindingParam)

Example 22 with RpcBindingParam

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;
    }
}
Also used : RpcBinding(com.alipay.sofa.rpc.boot.runtime.binding.RpcBinding) BoltBinding(com.alipay.sofa.rpc.boot.runtime.binding.BoltBinding) RpcBindingParam(com.alipay.sofa.rpc.boot.runtime.param.RpcBindingParam) BoltBindingParam(com.alipay.sofa.rpc.boot.runtime.param.BoltBindingParam) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 23 with RpcBindingParam

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());
}
Also used : BoltBinding(com.alipay.sofa.rpc.boot.runtime.binding.BoltBinding) RpcBindingParam(com.alipay.sofa.rpc.boot.runtime.param.RpcBindingParam) BoltBindingParam(com.alipay.sofa.rpc.boot.runtime.param.BoltBindingParam)

Example 24 with RpcBindingParam

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());
}
Also used : DubboBindingParam(com.alipay.sofa.rpc.boot.runtime.param.DubboBindingParam) DubboBinding(com.alipay.sofa.rpc.boot.runtime.binding.DubboBinding) RpcBindingParam(com.alipay.sofa.rpc.boot.runtime.param.RpcBindingParam)

Example 25 with RpcBindingParam

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;
}
Also used : RegistryConfig(com.alipay.sofa.rpc.config.RegistryConfig) ProviderConfig(com.alipay.sofa.rpc.config.ProviderConfig) RpcBindingParam(com.alipay.sofa.rpc.boot.runtime.param.RpcBindingParam) UserThreadPool(com.alipay.sofa.rpc.server.UserThreadPool) MethodConfig(com.alipay.sofa.rpc.config.MethodConfig) ServerConfig(com.alipay.sofa.rpc.config.ServerConfig) Filter(com.alipay.sofa.rpc.filter.Filter) ApplicationConfig(com.alipay.sofa.rpc.config.ApplicationConfig)

Aggregations

RpcBindingParam (com.alipay.sofa.rpc.boot.runtime.param.RpcBindingParam)34 BoltBinding (com.alipay.sofa.rpc.boot.runtime.binding.BoltBinding)6 BoltBindingParam (com.alipay.sofa.rpc.boot.runtime.param.BoltBindingParam)6 DubboBinding (com.alipay.sofa.rpc.boot.runtime.binding.DubboBinding)4 H2cBinding (com.alipay.sofa.rpc.boot.runtime.binding.H2cBinding)4 HttpBinding (com.alipay.sofa.rpc.boot.runtime.binding.HttpBinding)4 RestBinding (com.alipay.sofa.rpc.boot.runtime.binding.RestBinding)4 TripleBinding (com.alipay.sofa.rpc.boot.runtime.binding.TripleBinding)4 DubboBindingParam (com.alipay.sofa.rpc.boot.runtime.param.DubboBindingParam)4 H2cBindingParam (com.alipay.sofa.rpc.boot.runtime.param.H2cBindingParam)4 HttpBindingParam (com.alipay.sofa.rpc.boot.runtime.param.HttpBindingParam)4 RestBindingParam (com.alipay.sofa.rpc.boot.runtime.param.RestBindingParam)4 TripleBindingParam (com.alipay.sofa.rpc.boot.runtime.param.TripleBindingParam)4 ApplicationConfig (com.alipay.sofa.rpc.config.ApplicationConfig)4 MethodConfig (com.alipay.sofa.rpc.config.MethodConfig)4 RegistryConfig (com.alipay.sofa.rpc.config.RegistryConfig)4 Filter (com.alipay.sofa.rpc.filter.Filter)4 SofaBootRpcRuntimeException (com.alipay.sofa.rpc.boot.common.SofaBootRpcRuntimeException)2 RpcBinding (com.alipay.sofa.rpc.boot.runtime.binding.RpcBinding)2 ConsumerConfig (com.alipay.sofa.rpc.config.ConsumerConfig)2