Java Code Examples for org.apache.dubbo.config.ReferenceConfig#setGroup()
The following examples show how to use
org.apache.dubbo.config.ReferenceConfig#setGroup() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DirectServiceIT.java From dubbo-samples with Apache License 2.0 | 6 votes |
@Test public void testGeneric() throws Exception { ApplicationConfig application = new ApplicationConfig(); application.setName("direct-consumer"); ReferenceConfig<GenericService> reference = new ReferenceConfig<>(); reference.setUrl("dubbo://" + providerAddress + ":20880/" + DirectService.class.getName()); reference.setVersion("1.0.0-daily"); reference.setGroup("test"); reference.setGeneric(true); reference.setApplication(application); reference.setInterface(DirectService.class.getName()); GenericService genericService = reference.get(); Object obj = genericService.$invoke("sayHello", new String[]{String.class.getName()}, new Object[]{ "generic" }); String str = (String) obj; TestCase.assertTrue(str.startsWith("Hello generic")); }
Example 2
Source File: JbootDubborpc.java From jboot with Apache License 2.0 | 6 votes |
@Override public <T> T onServiceCreate(Class<T> interfaceClass, JbootrpcReferenceConfig config) { ReferenceConfig<T> reference = DubboUtil.toReferenceConfig(config); reference.setInterface(interfaceClass); String directUrl = rpcConfig.getUrl(interfaceClass.getName()); if (StrUtil.isNotBlank(directUrl)) { reference.setUrl(directUrl); } String consumer = rpcConfig.getConsumer(interfaceClass.getName()); if (consumer != null) { reference.setConsumer(DubboUtil.getConsumer(consumer)); } if (reference.getGroup() == null) { reference.setGroup(rpcConfig.getGroup(interfaceClass.getName())); } if (reference.getVersion() == null) { reference.setVersion(rpcConfig.getVersion(interfaceClass.getName())); } return reference.get(); }
Example 3
Source File: ApplicationConfigCache.java From soul with Apache License 2.0 | 5 votes |
/** * Build reference config. * * @param metaData the meta data * @return the reference config */ public ReferenceConfig<GenericService> build(final MetaData metaData) { ReferenceConfig<GenericService> reference = new ReferenceConfig<>(); reference.setGeneric(true); reference.setApplication(applicationConfig); reference.setRegistry(registryConfig); reference.setInterface(metaData.getServiceName()); reference.setProtocol("dubbo"); String rpcExt = metaData.getRpcExt(); DubboParamExtInfo dubboParamExtInfo = GsonUtils.getInstance().fromJson(rpcExt, DubboParamExtInfo.class); if (Objects.nonNull(dubboParamExtInfo)) { if (StringUtils.isNoneBlank(dubboParamExtInfo.getVersion())) { reference.setVersion(dubboParamExtInfo.getVersion()); } if (StringUtils.isNoneBlank(dubboParamExtInfo.getGroup())) { reference.setGroup(dubboParamExtInfo.getGroup()); } if (StringUtils.isNoneBlank(dubboParamExtInfo.getLoadbalance())) { final String loadBalance = dubboParamExtInfo.getLoadbalance(); reference.setLoadbalance(buildLoadBalanceName(loadBalance)); } Optional.ofNullable(dubboParamExtInfo.getTimeout()).ifPresent(reference::setTimeout); Optional.ofNullable(dubboParamExtInfo.getRetries()).ifPresent(reference::setRetries); } Object obj = reference.get(); if (obj != null) { log.info("init apache dubbo reference success there meteData is :{}", metaData.toString()); cache.put(metaData.getServiceName(), reference); } return reference; }
Example 4
Source File: DirectServiceIT.java From dubbo-samples with Apache License 2.0 | 5 votes |
@Test public void testApi() throws Exception { ApplicationConfig application = new ApplicationConfig(); application.setName("direct-consumer"); ReferenceConfig<DirectService> reference = new ReferenceConfig<>(); reference.setUrl("dubbo://" + providerAddress + ":20880/" + DirectService.class.getName()); reference.setVersion("1.0.0-daily"); reference.setGroup("test"); reference.setApplication(application); reference.setInterface(DirectService.class.getName()); DirectService service = reference.get(); String result = service.sayHello("api"); TestCase.assertTrue(result.startsWith("Hello api")); }
Example 5
Source File: DubboProxyService.java From bird-java with MIT License | 5 votes |
private ReferenceConfig<GenericService> buildReferenceConfig(final DubboHandle dubboHandle) { ReferenceConfig<GenericService> reference = REFERENCE_CONFIG_MAP.get(dubboHandle); if (Objects.isNull(reference)) { reference = new ReferenceConfig<>(); reference.setInterface(dubboHandle.getInterfaceName()); reference.setGeneric(true); reference.setRegistry(cacheRegistry(dubboHandle)); reference.setConsumer(getConsumer(dubboHandle)); if (StringUtils.isNoneBlank(dubboHandle.getVersion())) { reference.setVersion(dubboHandle.getVersion()); } if (StringUtils.isNoneBlank(dubboHandle.getProtocol())) { reference.setProtocol(dubboHandle.getProtocol()); } if (StringUtils.isNoneBlank(dubboHandle.getGroup())) { reference.setGroup(dubboHandle.getGroup()); } if (StringUtils.isNoneBlank(dubboHandle.getLoadBalance())) { reference.setLoadbalance(dubboHandle.getLoadBalance()); } Optional.ofNullable(dubboHandle.getTimeout()).ifPresent(reference::setTimeout); Optional.ofNullable(dubboHandle.getRetries()).ifPresent(reference::setRetries); REFERENCE_CONFIG_MAP.put(dubboHandle, reference); } return reference; }