use of com.alipay.sofa.rpc.config.ProviderConfig in project sofa-boot by alipay.
the class ProcessorAutoConfigTest method testProperty.
@Test
public void testProperty() {
Assert.assertEquals("apollo", dynamicConfigProcessor.getDynamicConfig());
Assert.assertEquals("abc", consumerMockProcessor.getMockUrl());
ProviderConfig providerConfig = new ProviderConfig();
providerConfig.setRegister(true);
providerRegisterProcessor.processorProvider(providerConfig);
Assert.assertFalse(providerConfig.isRegister());
}
use of com.alipay.sofa.rpc.config.ProviderConfig in project sofa-boot by alipay.
the class ProviderRegisterProcessorTest method test.
@Test
public void test() {
ProviderConfig providerConfig = new ProviderConfig();
providerConfig.setRegister(true);
providerRegisterProcessor.processorProvider(providerConfig);
Assert.assertTrue(providerConfig.isRegister());
System.setProperty("sofa.rpc.registry.disablePub", "true");
providerRegisterProcessor.processorProvider(providerConfig);
Assert.assertFalse(providerConfig.isRegister());
System.clearProperty("sofa.rpc.registry.disablePub");
}
use of com.alipay.sofa.rpc.config.ProviderConfig in project sofa-boot by alipay.
the class ProviderConfigContainer method publishAllProviderConfig.
/**
* 发布所有 ProviderConfig 元数据信息到注册中心
*/
public void publishAllProviderConfig() {
for (ProviderConfig providerConfig : getAllProviderConfig()) {
ServerConfig serverConfig = (ServerConfig) providerConfig.getServer().get(0);
if (!serverConfig.getProtocol().equalsIgnoreCase(SofaBootRpcConfigConstants.RPC_PROTOCOL_DUBBO)) {
providerConfig.setRegister(true);
List<RegistryConfig> registrys = providerConfig.getRegistry();
for (RegistryConfig registryConfig : registrys) {
Registry registry = RegistryFactory.getRegistry(registryConfig);
registry.init();
registry.start();
registry.register(providerConfig);
if (LOGGER.isInfoEnabled()) {
LOGGER.info("service published. interfaceId[" + providerConfig.getInterfaceId() + "]; protocol[" + serverConfig.getProtocol() + "]");
}
}
}
}
}
use of com.alipay.sofa.rpc.config.ProviderConfig in project sofa-boot by alipay.
the class ProviderConfigContainer method exportAllDubboProvideConfig.
/**
* export所有 Dubbo 类型的 ProviderConfig
*/
public void exportAllDubboProvideConfig() {
for (ProviderConfig providerConfig : getAllProviderConfig()) {
ServerConfig serverConfig = (ServerConfig) providerConfig.getServer().get(0);
if (serverConfig.getProtocol().equalsIgnoreCase(SofaBootRpcConfigConstants.RPC_PROTOCOL_DUBBO)) {
providerConfig.setRegister(true);
providerConfig.export();
if (LOGGER.isInfoEnabled()) {
LOGGER.info("service published. interfaceId[" + providerConfig.getInterfaceId() + "]; protocol[" + serverConfig.getProtocol() + "]");
}
}
}
}
use of com.alipay.sofa.rpc.config.ProviderConfig 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);
}
}
Aggregations