use of com.alipay.sofa.rpc.boot.container.ProviderConfigContainer in project sofa-boot by sofastack.
the class RpcBindingAdapter method preOutBinding.
/**
* pre out binding
*
* @param contract binding contract
* @param binding binding object
* @param target binding target
* @param sofaRuntimeContext sofa runtime context
*/
@Override
public void preOutBinding(Object contract, RpcBinding binding, Object target, SofaRuntimeContext sofaRuntimeContext) {
ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager().getRootApplicationContext();
ProviderConfigContainer providerConfigContainer = applicationContext.getBean(ProviderConfigContainer.class);
String uniqueName = providerConfigContainer.createUniqueName((Contract) contract, binding);
ProviderConfigHelper providerConfigHelper = applicationContext.getBean(ProviderConfigHelper.class);
ProviderConfig providerConfig = providerConfigHelper.getProviderConfig((Contract) contract, binding, target);
try {
providerConfigContainer.addProviderConfig(uniqueName, providerConfig);
} catch (Exception e) {
throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_PUBLISH_FAIL), e);
}
}
use of com.alipay.sofa.rpc.boot.container.ProviderConfigContainer in project sofa-boot by sofastack.
the class RpcBindingAdapter method postUnoutBinding.
/**
* post unout binding
*
* @param contract binding contract
* @param binding binding object
* @param target binding target
* @param sofaRuntimeContext sofa runtime context
*/
@Override
public void postUnoutBinding(Object contract, RpcBinding binding, Object target, SofaRuntimeContext sofaRuntimeContext) {
ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager().getRootApplicationContext();
ProviderConfigContainer providerConfigContainer = applicationContext.getBean(ProviderConfigContainer.class);
String key = providerConfigContainer.createUniqueName((Contract) contract, binding);
try {
providerConfigContainer.removeProviderConfig(key);
} catch (Exception e) {
throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_POST_UNPUBLISH_FAIL), e);
}
}
use of com.alipay.sofa.rpc.boot.container.ProviderConfigContainer in project sofa-boot by alipay.
the class RpcBindingAdapter method preUnoutBinding.
/**
* pre unout binding
*
* @param contract binding contract
* @param binding binding object
* @param target binding target
* @param sofaRuntimeContext sofa runtime context
*/
@Override
public void preUnoutBinding(Object contract, RpcBinding binding, Object target, SofaRuntimeContext sofaRuntimeContext) {
ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager().getRootApplicationContext();
ProviderConfigContainer providerConfigContainer = applicationContext.getBean(ProviderConfigContainer.class);
String key = providerConfigContainer.createUniqueName((Contract) contract, binding);
ProviderConfig providerConfig = providerConfigContainer.getProviderConfig(key);
try {
providerConfig.unExport();
} catch (Exception e) {
throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_PRE_UNPUBLISH_FAIL), e);
}
}
use of com.alipay.sofa.rpc.boot.container.ProviderConfigContainer in project sofa-boot by alipay.
the class RpcBindingAdapter method postUnoutBinding.
/**
* post unout binding
*
* @param contract binding contract
* @param binding binding object
* @param target binding target
* @param sofaRuntimeContext sofa runtime context
*/
@Override
public void postUnoutBinding(Object contract, RpcBinding binding, Object target, SofaRuntimeContext sofaRuntimeContext) {
ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager().getRootApplicationContext();
ProviderConfigContainer providerConfigContainer = applicationContext.getBean(ProviderConfigContainer.class);
String key = providerConfigContainer.createUniqueName((Contract) contract, binding);
try {
providerConfigContainer.removeProviderConfig(key);
} catch (Exception e) {
throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_POST_UNPUBLISH_FAIL), e);
}
}
use of com.alipay.sofa.rpc.boot.container.ProviderConfigContainer in project sofa-boot by alipay.
the class RpcBindingAdapter method outBinding.
/**
* out binding, out binding means provide service
*
* @param contract binding contract
* @param binding binding object
* @param target binding target
* @param sofaRuntimeContext sofa runtime context
* @return binding result
*/
@Override
public Object outBinding(Object contract, RpcBinding binding, Object target, SofaRuntimeContext sofaRuntimeContext) {
ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager().getRootApplicationContext();
ProviderConfigContainer providerConfigContainer = applicationContext.getBean(ProviderConfigContainer.class);
ProcessorContainer processorContainer = applicationContext.getBean(ProcessorContainer.class);
String uniqueName = providerConfigContainer.createUniqueName((Contract) contract, binding);
ProviderConfig providerConfig = providerConfigContainer.getProviderConfig(uniqueName);
processorContainer.processorProvider(providerConfig);
if (providerConfig == null) {
throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.INFO_SERVICE_METADATA_IS_NULL, uniqueName));
}
try {
providerConfig.export();
} catch (Exception e) {
throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_PUBLISH_FAIL), e);
}
if (providerConfigContainer.isAllowPublish()) {
providerConfig.setRegister(true);
List<RegistryConfig> registrys = providerConfig.getRegistry();
for (RegistryConfig registryConfig : registrys) {
Registry registry = RegistryFactory.getRegistry(registryConfig);
registry.init();
registry.start();
registry.register(providerConfig);
}
}
return Boolean.TRUE;
}
Aggregations