You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "11huangxing (via GitHub)" <gi...@apache.org> on 2023/03/13 09:12:29 UTC

[GitHub] [dubbo] 11huangxing commented on issue #11809: dubbo 31.7版本中如何设置ReferenceBean的ip、port、interface、group、payload

11huangxing commented on issue #11809:
URL: https://github.com/apache/dubbo/issues/11809#issuecomment-1465767974

   这是之前的代码:
   T service = (T)dubboServiceCache.computeIfAbsent(cacheKey, k -> {
               log.debug("dubbo service not exist, ready to get one.");
               ReferenceBean<T> referenceBean = new ReferenceBean<>();
               referenceBean.setApplicationContext(applicationContext);
               referenceBean.setInterface(serviceClass);
               if (timeout != null)
               {
                   referenceBean.setTimeout(timeout);
               }
   
               if (StringUtils.isNotBlank(group))
               {
                   referenceBean.setGroup(group);
               }
               if (StringUtils.isNotBlank(ip) && port > 0)
               {
                   referenceBean.setUrl("dubbo://" + ip + ":" + port);
               }
   
               ProtocolConfig protocolConfig = getBean(ProtocolConfig.class);
               if (protocolConfig.getPayload() != null)
               {
                   Map<String, String> refParams = referenceBean.getParameters();
                   if (null == refParams)
                   {
                       refParams = new HashMap<>();
                   }
   
                   refParams.put(Constants.PAYLOAD_KEY, protocolConfig.getPayload().toString());
                   log.debug("magic set reference config parameters: {}", refParams);
                   referenceBean.setParameters(refParams);
               }


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org