gpt4 book ai didi

org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryProperties.getMetadata()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 10:29:31 40 4
gpt4 key购买 nike

本文整理了Java中org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryProperties.getMetadata()方法的一些代码示例,展示了ZookeeperDiscoveryProperties.getMetadata()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperDiscoveryProperties.getMetadata()方法的具体详情如下:
包路径:org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryProperties
类名称:ZookeeperDiscoveryProperties
方法名:getMetadata

ZookeeperDiscoveryProperties.getMetadata介绍

暂无

代码示例

代码示例来源:origin: Nepxion/Discovery

@Override
  protected Object afterInitialization(ConfigurableApplicationContext applicationContext, Object bean, String beanName) throws BeansException {
    if (bean instanceof ZookeeperServiceRegistry) {
      ZookeeperServiceRegistry zookeeperServiceRegistry = (ZookeeperServiceRegistry) bean;

      return new ZookeeperServiceRegistryDecorator(zookeeperServiceRegistry, applicationContext);
    } else if (bean instanceof ZookeeperDiscoveryProperties) {
      ConfigurableEnvironment environment = applicationContext.getEnvironment();

      ZookeeperDiscoveryProperties zookeeperDiscoveryProperties = (ZookeeperDiscoveryProperties) bean;
      zookeeperDiscoveryProperties.setPreferIpAddress(true);

      Map<String, String> metadata = zookeeperDiscoveryProperties.getMetadata();
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_DISCOVERY_PLUGIN, ZookeeperConstant.DISCOVERY_PLUGIN);
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_DISCOVERY_VERSION, DiscoveryConstant.DISCOVERY_VERSION);
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_REGISTER_CONTROL_ENABLED, PluginContextAware.isRegisterControlEnabled(environment).toString());
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_DISCOVERY_CONTROL_ENABLED, PluginContextAware.isDiscoveryControlEnabled(environment).toString());
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_CONFIG_REST_CONTROL_ENABLED, PluginContextAware.isConfigRestControlEnabled(environment).toString());
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_GROUP_KEY, PluginContextAware.getGroupKey(environment));
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_CONTEXT_PATH, PluginContextAware.getContextPath(environment));

      MetadataUtil.filter(metadata);

      return bean;
    } else {
      return bean;
    }
  }
}

代码示例来源:origin: spring-cloud/spring-cloud-zookeeper

@PostConstruct
public void init() {
  if (this.properties == null || this.server == null) {
    return;
  }
  String prefix = this.server.getPrefix();
  if (StringUtils.hasText(prefix)) {
    this.properties.getMetadata().put("configPath", prefix);
  }
}

代码示例来源:origin: SpringCloud/spring-cloud-gray

@Bean
  @ConditionalOnMissingBean
  public InstanceLocalInfo instanceLocalInfo(@Autowired Registration registration,
                        @Autowired ZookeeperDiscoveryProperties properties)
      throws ConfigurationException {
    String instanceId;
    if (properties.getMetadata().containsKey(METADATA_KEY_INSTANCE_ID)) {
      instanceId = properties.getMetadata().get(METADATA_KEY_INSTANCE_ID);
    } else {
      throw new ConfigurationException("Unable to find config spring.cloud.zookeeper.discovery.metadata" +
          ".instanceId!");
    }

    InstanceLocalInfo localInfo = new InstanceLocalInfo();
    localInfo.setInstanceId(instanceId);
    localInfo.setServiceId(registration.getServiceId());
    localInfo.setGray(false);
    return localInfo;
  }
}

代码示例来源:origin: com.nepxion/discovery-plugin-framework-zookeeper

@Override
  protected Object afterInitialization(ConfigurableApplicationContext applicationContext, Object bean, String beanName) throws BeansException {
    if (bean instanceof ZookeeperServiceRegistry) {
      ZookeeperServiceRegistry zookeeperServiceRegistry = (ZookeeperServiceRegistry) bean;

      return new ZookeeperServiceRegistryDecorator(zookeeperServiceRegistry, applicationContext);
    } else if (bean instanceof ZookeeperDiscoveryProperties) {
      ConfigurableEnvironment environment = applicationContext.getEnvironment();

      ZookeeperDiscoveryProperties zookeeperDiscoveryProperties = (ZookeeperDiscoveryProperties) bean;
      zookeeperDiscoveryProperties.setPreferIpAddress(true);

      Map<String, String> metadata = zookeeperDiscoveryProperties.getMetadata();
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_DISCOVERY_PLUGIN, ZookeeperConstant.DISCOVERY_PLUGIN);
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_DISCOVERY_VERSION, DiscoveryConstant.DISCOVERY_VERSION);
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_REGISTER_CONTROL_ENABLED, PluginContextAware.isRegisterControlEnabled(environment).toString());
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_DISCOVERY_CONTROL_ENABLED, PluginContextAware.isDiscoveryControlEnabled(environment).toString());
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_CONFIG_REST_CONTROL_ENABLED, PluginContextAware.isConfigRestControlEnabled(environment).toString());
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_GROUP_KEY, PluginContextAware.getGroupKey(environment));
      metadata.put(DiscoveryConstant.SPRING_APPLICATION_CONTEXT_PATH, PluginContextAware.getContextPath(environment));

      MetadataUtil.filter(metadata);

      return bean;
    } else {
      return bean;
    }
  }
}

代码示例来源:origin: spring-cloud/spring-cloud-zookeeper

@Bean
@ConditionalOnMissingBean(ZookeeperRegistration.class)
public ServiceInstanceRegistration serviceInstanceRegistration(
    ApplicationContext context, ZookeeperDiscoveryProperties properties) {
  String appName = context.getEnvironment().getProperty("spring.application.name",
      "application");
  String host = properties.getInstanceHost();
  if (!StringUtils.hasText(host)) {
    throw new IllegalStateException("instanceHost must not be empty");
  }
  ZookeeperInstance zookeeperInstance = new ZookeeperInstance(context.getId(),
      appName, properties.getMetadata());
  RegistrationBuilder builder = ServiceInstanceRegistration.builder().address(host)
      .name(appName).payload(zookeeperInstance)
      .uriSpec(properties.getUriSpec());
  if (properties.getInstanceSslPort() != null) {
    builder.sslPort(properties.getInstanceSslPort());
  }
  if (properties.getInstanceId() != null) {
    builder.id(properties.getInstanceId());
  }
  // TODO add customizer?
  return builder.build();
}

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com