You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/05/22 01:22:10 UTC

[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables

liubao68 commented on a change in pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769#discussion_r428996111



##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/ZeroConfigRegistryApplicationListener.java
##########
@@ -52,32 +53,36 @@
   private static final Logger LOGGER = LoggerFactory
       .getLogger(ZeroConfigRegistryApplicationListener.class);
 
-  private ApplicationContext applicationContext;
   private MulticastSocket multicastSocket;
 
   @Override
   public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
 
     // same mechanism as Local registry to enable the Zero Config registry
-    String flag = System.getProperty(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_FLAG);
-    if (flag != null && flag.equals(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_ENABLE_FLAG)) {
-      this.applicationContext = applicationContext;
-      BeanUtils.setContext(applicationContext);
-      ServerUtil.init();
-      ClientUtil.init();
-
-      try {
-        this.multicastSocket = new MulticastSocket();
-      } catch (IOException e) {
-        LOGGER.error("Failed create MulticastSocket object", e);
-      }
-
-      Function<ServiceRegistry, ServiceRegistryClient> registryClientConstructor =
-          serviceRegistry -> new ZeroConfigRegistryClientImpl(new ZeroConfigRegistryService(),
-              multicastSocket, new RestTemplate());
-
-      ServiceRegistryConfig.INSTANCE.setServiceRegistryClientConstructor(registryClientConstructor);
+    boolean enable = DynamicPropertyFactory.getInstance()
+        .getBooleanProperty("servicecomb.zeroconfig.enabled", false).get();

Review comment:
       I think default value to 'true' is better. Because when users use zeroconfig, they have to add pom dependency implicitly. It is falst when zeroconfig module is not included. I set 'local/service center' default to 'true'. see https://github.com/apache/servicecomb-java-chassis/blob/master/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java




----------------------------------------------------------------
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.

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