Search in sources :

Example 1 with ProviderConfigHelper

use of com.alipay.sofa.rpc.boot.runtime.adapter.helper.ProviderConfigHelper 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);
    }
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ProviderConfig(com.alipay.sofa.rpc.config.ProviderConfig) ProviderConfigContainer(com.alipay.sofa.rpc.boot.container.ProviderConfigContainer) ProviderConfigHelper(com.alipay.sofa.rpc.boot.runtime.adapter.helper.ProviderConfigHelper) ServiceRuntimeException(com.alipay.sofa.runtime.api.ServiceRuntimeException) ServiceRuntimeException(com.alipay.sofa.runtime.api.ServiceRuntimeException)

Example 2 with ProviderConfigHelper

use of com.alipay.sofa.rpc.boot.runtime.adapter.helper.ProviderConfigHelper in project sofa-boot by alipay.

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);
    }
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ProviderConfig(com.alipay.sofa.rpc.config.ProviderConfig) ProviderConfigContainer(com.alipay.sofa.rpc.boot.container.ProviderConfigContainer) ProviderConfigHelper(com.alipay.sofa.rpc.boot.runtime.adapter.helper.ProviderConfigHelper) ServiceRuntimeException(com.alipay.sofa.runtime.api.ServiceRuntimeException) ServiceRuntimeException(com.alipay.sofa.runtime.api.ServiceRuntimeException)

Aggregations

ProviderConfigContainer (com.alipay.sofa.rpc.boot.container.ProviderConfigContainer)2 ProviderConfigHelper (com.alipay.sofa.rpc.boot.runtime.adapter.helper.ProviderConfigHelper)2 ProviderConfig (com.alipay.sofa.rpc.config.ProviderConfig)2 ServiceRuntimeException (com.alipay.sofa.runtime.api.ServiceRuntimeException)2 ApplicationContext (org.springframework.context.ApplicationContext)2