Register ZookeeperProperties in Bootstraper (#331)
Co-authored-by: Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com>
This commit is contained in:
@@ -35,6 +35,7 @@ import org.springframework.cloud.config.client.ConfigClientProperties;
|
||||
import org.springframework.cloud.config.client.ConfigServerConfigDataLocationResolver.PropertyResolver;
|
||||
import org.springframework.cloud.config.client.ConfigServerInstanceProvider;
|
||||
import org.springframework.cloud.zookeeper.CuratorFactory;
|
||||
import org.springframework.cloud.zookeeper.ZookeeperProperties;
|
||||
import org.springframework.cloud.zookeeper.discovery.ConditionalOnZookeeperDiscoveryEnabled;
|
||||
import org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryClient;
|
||||
import org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryProperties;
|
||||
@@ -67,6 +68,17 @@ public class ZookeeperConfigServerBootstrapper implements BootstrapRegistryIniti
|
||||
return;
|
||||
}
|
||||
|
||||
//Register ZookeeperProperties instead of in CuratorFactor.registerCurator here so we can properly resolve the properties.
|
||||
//We need to use the PropertyResolver to do so but that is not available in CuratorFactory since it is a class
|
||||
//from Spring Cloud Config.
|
||||
registry.registerIfAbsent(ZookeeperProperties.class, context -> {
|
||||
if (!isEnabled(context)) {
|
||||
return null;
|
||||
}
|
||||
PropertyResolver propertyResolver = getPropertyResolver(context);
|
||||
return propertyResolver.resolveOrCreateConfigurationProperties(ZookeeperProperties.PREFIX, ZookeeperProperties.class);
|
||||
});
|
||||
|
||||
// create curator
|
||||
CuratorFactory.registerCurator(registry, null, true, ZookeeperConfigServerBootstrapper::isEnabled);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user