Java Code Examples for com.alibaba.dubbo.config.ReferenceConfig#setVersion()
The following examples show how to use
com.alibaba.dubbo.config.ReferenceConfig#setVersion() .
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: DubboUtils.java From java-master with Apache License 2.0 | 6 votes |
private static <T> ReferenceConfig<T> getReferenceConfig(Class<?> interfaceClass, String group, String version, String host) { String referenceKey = interfaceClass.getName(); ReferenceConfig<T> referenceConfig = new ReferenceConfig<>(); referenceConfig.setApplication(application); referenceConfig.setRegistry(getRegistryConfig(group, version)); referenceConfig.setInterface(interfaceClass); referenceConfig.setVersion(version); referenceConfig.setTimeout(30000); referenceConfig.setGeneric(true); if (StringUtils.isNotBlank(host)) { String url = String.format("dubbo://%s/%s", host, referenceKey); referenceConfig.setUrl(url); } return referenceConfig; }
Example 2
Source File: DubboSinkFunction.java From alchemy with Apache License 2.0 | 6 votes |
private ReferenceConfig<GenericService> referenceConfig(DubboProperties properties) throws Exception { ApplicationConfig application = new ApplicationConfig(); application.setName(properties.getApplicationName()); ReferenceConfig<GenericService> reference = new ReferenceConfig<>(); reference.setApplication(application); reference.setRegistry(new RegistryConfig(properties.getRegistryAddr())); reference.setInterface(properties.getInterfaceName()); reference.setVersion(properties.getVersion()); reference.setGeneric(true); reference.setCheck(false); reference.setInit(true); if(properties.getProperties() != null){ BeanUtils.copyProperties(reference, properties.getProperties()); } return reference; }
Example 3
Source File: ReferenceManager.java From swagger-dubbo with Apache License 2.0 | 6 votes |
public Object getProxy(String interfaceClass) { Set<Entry<Class<?>, Object>> entrySet = interfaceMapProxy.entrySet(); for (Entry<Class<?>, Object> entry : entrySet) { if (entry.getKey().getName().equals(interfaceClass)) { return entry.getValue(); } } for (ServiceBean<?> service : services) { if (interfaceClass.equals(service.getInterfaceClass().getName())) { ReferenceConfig<Object> reference = new ReferenceConfig<Object>(); reference.setApplication(service.getApplication()); reference.setRegistry(service.getRegistry()); reference.setRegistries(service.getRegistries()); reference.setInterface(service.getInterfaceClass()); reference.setVersion(service.getVersion()); interfaceMapProxy.put(service.getInterfaceClass(), reference.get()); return reference.get(); } } return null; }
Example 4
Source File: DubboInvoker.java From dubbo-postman with MIT License | 5 votes |
ReferenceConfig<GenericService> createReference(PostmanDubboRequest request, DubboParamValue rpcParamValue){ ReferenceConfig<GenericService> newReference = new ReferenceConfig<GenericService>(); //设置默认超时无限制,用于在本地调试的时候用 newReference.setTimeout(Integer.MAX_VALUE); newReference.setApplication(application); newReference.setInterface(request.getInterfaceName()); String group = request.getGroup(); //default是我加的,dubbo默认是没有的 if(group.isEmpty() || group.equals("default")){ }else{ newReference.setGroup(group); } if(rpcParamValue.isUseDubbo()){ //直连 newReference.setUrl(rpcParamValue.getDubboUrl()); logger.info("直连dubbo地址:"+rpcParamValue.getDubboUrl()); }else{ //通过zk访问 newReference.setRegistry(new RegistryConfig(rpcParamValue.getRegistry())); } newReference.setVersion(request.getVersion()); newReference.setGeneric(true); //hard code newReference.setRetries(1); return newReference; }
Example 5
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 aliaba dubbo reference success there meteData is :{}", metaData.toString()); cache.put(metaData.getServiceName(), reference); } return reference; }
Example 6
Source File: DubboConsumerBootstrap.java From sofa-rpc with Apache License 2.0 | 5 votes |
private void copyConsumer(ConsumerConfig<T> consumerConfig, ReferenceConfig<T> referenceConfig) { referenceConfig.setId(consumerConfig.getId()); referenceConfig.setInterface(consumerConfig.getInterfaceId()); referenceConfig.setGroup(consumerConfig.getUniqueId()); referenceConfig.setVersion("1.0"); referenceConfig.setActives(consumerConfig.getConcurrents()); referenceConfig.setCluster(consumerConfig.getCluster()); referenceConfig.setConnections(consumerConfig.getConnectionNum()); referenceConfig.setRetries(consumerConfig.getRetries()); referenceConfig.setProxy(consumerConfig.getProxy()); referenceConfig.setTimeout(consumerConfig.getTimeout()); referenceConfig.setUrl(consumerConfig.getDirectUrl()); referenceConfig.setCheck(consumerConfig.isCheck()); referenceConfig.setLazy(consumerConfig.isLazy()); referenceConfig.setGeneric(consumerConfig.isGeneric()); String invokeType = consumerConfig.getInvokeType(); if (invokeType != null) { if (RpcConstants.INVOKER_TYPE_ONEWAY.equals(invokeType)) { referenceConfig.setSent(false); } if (RpcConstants.INVOKER_TYPE_CALLBACK.equals(invokeType) || RpcConstants.INVOKER_TYPE_FUTURE.equals(invokeType)) { referenceConfig.setAsync(true); } } referenceConfig.setParameters(consumerConfig.getParameters()); }
Example 7
Source File: DubboMonitorConsumerFactory.java From EasyTransaction with Apache License 2.0 | 5 votes |
private GenericService generateService(String appId, Class<?> monitorInterface) { ReferenceConfig<GenericService> referenceConfig = new ReferenceConfig<GenericService>(); referenceConfig.setInterface(monitorInterface); // 弱类型接口名 referenceConfig.setVersion("1.0.0"); referenceConfig.setGeneric(true); // 声明为泛化接口 referenceConfig.setGroup(appId + "-" + monitorInterface.getSimpleName()); referenceConfig.setCheck(false); if(applicationConfig != null) { referenceConfig.setApplication(applicationConfig); } if(registryConfig != null) { referenceConfig.setRegistry(registryConfig); } if(protocolConfig != null) { referenceConfig.setProtocol(protocolConfig.getName()); } if(moduleConfig != null) { referenceConfig.setModule(moduleConfig); } if(monitorConfig != null) { referenceConfig.setMonitor(monitorConfig); } if(consumerConfig != null) { referenceConfig.setConsumer(consumerConfig); } if(customizationer != null) { customizationer.customDubboReferance(appId,null,referenceConfig); } return referenceConfig.get(); }
Example 8
Source File: DubboEasyTransRpcConsumerImpl.java From EasyTransaction with Apache License 2.0 | 4 votes |
private GenericService getCaller(String appId, String busCode,EasyTransRequest<?,?> request) { GenericService genericService = mapRef.get(getTargetKey(appId,busCode)); if(genericService == null){ List<Class<?>> typeArguments = ReflectUtil.getTypeArguments(EasyTransRequest.class, request.getClass()); Class<?> executorCLass = typeArguments.get(1); RelativeInterface annotation = executorCLass.getAnnotation(RelativeInterface.class); Class<?> value = annotation.value(); ReferenceConfig<GenericService> referenceConfig = new ReferenceConfig<GenericService>(); referenceConfig.setInterface(value.getName()); // 弱类型接口名 referenceConfig.setVersion("1.0.0"); referenceConfig.setGeneric(true); // 声明为泛化接口 referenceConfig.setGroup(appId + "-" + busCode); referenceConfig.setCheck(false); referenceConfig.setSticky(true);//设置粘滞连接以优化级联事务的级联提交性能 if(applicationConfig != null) { referenceConfig.setApplication(applicationConfig); } if(registryConfig != null) { referenceConfig.setRegistry(registryConfig); } if(protocolConfig != null) { referenceConfig.setProtocol(protocolConfig.getName()); } if(moduleConfig != null) { referenceConfig.setModule(moduleConfig); } if(monitorConfig != null) { referenceConfig.setMonitor(monitorConfig); } if(consumerConfig != null) { referenceConfig.setConsumer(consumerConfig); } if(customizationer != null) { customizationer.customDubboReferance(appId,busCode,referenceConfig); } genericService = referenceConfig.get(); mapRef.put(getTargetKey(appId,busCode), genericService); } return genericService; }