use of com.alipay.sofa.rpc.boot.container.ConsumerConfigContainer in project sofa-boot by alipay.
the class RpcBindingAdapter method unInBinding.
/**
* undo in binding
*
* @param contract
* @param binding
* @param sofaRuntimeContext
*/
@Override
public void unInBinding(Object contract, RpcBinding binding, SofaRuntimeContext sofaRuntimeContext) {
try {
ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager().getRootApplicationContext();
ConsumerConfigContainer consumerConfigContainer = applicationContext.getBean(ConsumerConfigContainer.class);
consumerConfigContainer.removeAndUnReferConsumerConfig(binding);
} catch (Exception e) {
throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_UNCOSUME_FAIL), e);
}
}
use of com.alipay.sofa.rpc.boot.container.ConsumerConfigContainer in project sofa-boot by alipay.
the class RpcBindingAdapter method inBinding.
/**
* in binding, in binding means reference service
*
* @param contract binding contract
* @param binding binding object
* @param sofaRuntimeContext sofa runtime context
*/
@Override
public Object inBinding(Object contract, RpcBinding binding, SofaRuntimeContext sofaRuntimeContext) {
ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager().getRootApplicationContext();
ConsumerConfigHelper consumerConfigHelper = applicationContext.getBean(ConsumerConfigHelper.class);
ConsumerConfigContainer consumerConfigContainer = applicationContext.getBean(ConsumerConfigContainer.class);
ProcessorContainer processorContainer = applicationContext.getBean(ProcessorContainer.class);
ConsumerConfig consumerConfig = consumerConfigHelper.getConsumerConfig((Contract) contract, binding);
processorContainer.processorConsumer(consumerConfig);
if (MockMode.LOCAL.equalsIgnoreCase(binding.getRpcBindingParam().getMockMode())) {
consumerConfig.setMockRef(consumerConfigHelper.getMockRef(binding, applicationContext));
}
consumerConfigContainer.addConsumerConfig(binding, consumerConfig);
try {
Object result = consumerConfig.refer();
binding.setConsumerConfig(consumerConfig);
return result;
} catch (Exception e) {
throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_CONSUME_FAIL), e);
}
}
use of com.alipay.sofa.rpc.boot.container.ConsumerConfigContainer in project sofa-boot by sofastack.
the class RpcBindingAdapter method inBinding.
/**
* in binding, in binding means reference service
*
* @param contract binding contract
* @param binding binding object
* @param sofaRuntimeContext sofa runtime context
*/
@Override
public Object inBinding(Object contract, RpcBinding binding, SofaRuntimeContext sofaRuntimeContext) {
ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager().getRootApplicationContext();
ConsumerConfigHelper consumerConfigHelper = applicationContext.getBean(ConsumerConfigHelper.class);
ConsumerConfigContainer consumerConfigContainer = applicationContext.getBean(ConsumerConfigContainer.class);
ProcessorContainer processorContainer = applicationContext.getBean(ProcessorContainer.class);
ConsumerConfig consumerConfig = consumerConfigHelper.getConsumerConfig((Contract) contract, binding);
processorContainer.processorConsumer(consumerConfig);
if (MockMode.LOCAL.equalsIgnoreCase(binding.getRpcBindingParam().getMockMode())) {
consumerConfig.setMockRef(consumerConfigHelper.getMockRef(binding, applicationContext));
}
consumerConfigContainer.addConsumerConfig(binding, consumerConfig);
try {
Object result = consumerConfig.refer();
binding.setConsumerConfig(consumerConfig);
return result;
} catch (Exception e) {
throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_CONSUME_FAIL), e);
}
}
use of com.alipay.sofa.rpc.boot.container.ConsumerConfigContainer in project sofa-boot by sofastack.
the class RpcBindingAdapter method unInBinding.
/**
* undo in binding
*
* @param contract
* @param binding
* @param sofaRuntimeContext
*/
@Override
public void unInBinding(Object contract, RpcBinding binding, SofaRuntimeContext sofaRuntimeContext) {
try {
ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager().getRootApplicationContext();
ConsumerConfigContainer consumerConfigContainer = applicationContext.getBean(ConsumerConfigContainer.class);
consumerConfigContainer.removeAndUnReferConsumerConfig(binding);
} catch (Exception e) {
throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_UNCOSUME_FAIL), e);
}
}
Aggregations