Java源码示例:de.codecentric.boot.admin.server.cloud.discovery.ServiceInstanceConverter
示例1
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties(prefix = "spring.boot.admin.discovery")
public InstanceDiscoveryListener instanceDiscoveryListener(ServiceInstanceConverter serviceInstanceConverter,
DiscoveryClient discoveryClient,
InstanceRegistry registry,
InstanceRepository repository) {
InstanceDiscoveryListener listener = new InstanceDiscoveryListener(discoveryClient, registry, repository);
listener.setConverter(serviceInstanceConverter);
return listener;
}
示例2
@Test
public void customServiceInstanceConverter() {
contextRunner.withUserConfiguration(SimpleDiscoveryClientAutoConfiguration.class,
TestCustomServiceInstanceConverterConfig.class
)
.run(context -> assertThat(context).getBean(ServiceInstanceConverter.class)
.isInstanceOf(CustomServiceInstanceConverter.class));
}
示例3
@Bean
@ConditionalOnMissingBean
public MossInstanceDiscoveryListener instanceDiscoveryListener(ServiceInstanceConverter serviceInstanceConverter,
InstanceRegistry registry,
InstanceRepository repository) {
MossInstanceDiscoveryListener listener = new MossInstanceDiscoveryListener(registry, repository);
listener.setConverter(serviceInstanceConverter);
listener.setIgnoredServices(Sets.newHashSet("consul"));
return listener;
}
示例4
@Bean
@ConditionalOnMissingBean
public MossInstanceDiscoveryListener instanceDiscoveryListener(ServiceInstanceConverter serviceInstanceConverter,
InstanceRegistry registry,
InstanceRepository repository) {
MossInstanceDiscoveryListener listener = new MossInstanceDiscoveryListener(registry, repository);
listener.setConverter(serviceInstanceConverter);
return listener;
}
示例5
@Bean
@ConditionalOnMissingBean
public MossInstanceDiscoveryListener instanceDiscoveryListener(ServiceInstanceConverter serviceInstanceConverter,
InstanceRegistry registry,
InstanceRepository repository) {
MossInstanceDiscoveryListener listener = new MossInstanceDiscoveryListener(registry, repository);
listener.setConverter(serviceInstanceConverter);
return listener;
}
示例6
@Bean
@ConditionalOnMissingBean
public MossInstanceDiscoveryListener instanceDiscoveryListener(ServiceInstanceConverter serviceInstanceConverter,
InstanceRegistry registry,
InstanceRepository repository,
ZookeeperDiscoveryClient zookeeperDiscoveryClient) {
MossInstanceDiscoveryListener listener = new MossInstanceDiscoveryListener(zookeeperDiscoveryClient, registry, repository);
listener.setConverter(serviceInstanceConverter);
return listener;
}
示例7
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties(prefix = "spring.boot.admin.discovery")
public InstanceDiscoveryListener instanceDiscoveryListener(ServiceInstanceConverter serviceInstanceConverter,
DiscoveryClient discoveryClient, InstanceRegistry registry, InstanceRepository repository) {
InstanceDiscoveryListener listener = new InstanceDiscoveryListener(discoveryClient, registry, repository);
listener.setConverter(serviceInstanceConverter);
return listener;
}
示例8
@Test
public void customServiceInstanceConverter() {
this.contextRunner
.withUserConfiguration(SimpleDiscoveryClientAutoConfiguration.class,
TestCustomServiceInstanceConverterConfig.class)
.run((context) -> assertThat(context).getBean(ServiceInstanceConverter.class)
.isInstanceOf(CustomServiceInstanceConverter.class));
}
示例9
@Bean
@ConditionalOnMissingBean({ServiceInstanceConverter.class})
@ConfigurationProperties(prefix = "spring.boot.admin.discovery.converter")
public DefaultServiceInstanceConverter serviceInstanceConverter() {
return new DefaultServiceInstanceConverter();
}
示例10
@Test
public void defaultServiceInstanceConverter() {
contextRunner.withUserConfiguration(SimpleDiscoveryClientAutoConfiguration.class)
.run(context -> assertThat(context.getBean(ServiceInstanceConverter.class)).isInstanceOf(
DefaultServiceInstanceConverter.class));
}
示例11
@Test
public void eurekaServiceInstanceConverter() {
contextRunner.withUserConfiguration(EurekaClientConfig.class)
.run(context -> assertThat(context).getBean(ServiceInstanceConverter.class)
.isInstanceOf(EurekaServiceInstanceConverter.class));
}
示例12
public void setConverter(ServiceInstanceConverter converter) {
this.converter = converter;
}
示例13
@ConditionalOnMissingBean({ServiceInstanceConverter.class})
@Bean
public DefaultServiceInstanceConverter serviceInstanceConverter() {
return new DefaultServiceInstanceConverter();
}
示例14
public void setConverter(ServiceInstanceConverter converter) {
this.converter = converter;
}
示例15
public void setConverter(ServiceInstanceConverter converter) {
this.converter = converter;
}
示例16
@Bean
@ConditionalOnMissingBean({ServiceInstanceConverter.class})
public DefaultServiceInstanceConverter serviceInstanceConverter() {
return new DefaultServiceInstanceConverter();
}
示例17
@Bean
@ConditionalOnMissingBean({ ServiceInstanceConverter.class })
@ConfigurationProperties(prefix = "spring.boot.admin.discovery.converter")
public DefaultServiceInstanceConverter serviceInstanceConverter() {
return new DefaultServiceInstanceConverter();
}
示例18
@Test
public void defaultServiceInstanceConverter() {
this.contextRunner.withUserConfiguration(SimpleDiscoveryClientAutoConfiguration.class)
.run((context) -> assertThat(context.getBean(ServiceInstanceConverter.class))
.isInstanceOf(DefaultServiceInstanceConverter.class));
}
示例19
@Test
public void eurekaServiceInstanceConverter() {
this.contextRunner.withUserConfiguration(EurekaClientConfig.class).run((context) -> assertThat(context)
.getBean(ServiceInstanceConverter.class).isInstanceOf(EurekaServiceInstanceConverter.class));
}
示例20
@Test
public void kubernetesServiceInstanceConverter() {
this.contextRunner.withUserConfiguration(KubernetesClientConfig.class).run((context) -> assertThat(context)
.getBean(ServiceInstanceConverter.class).isInstanceOf(KubernetesServiceInstanceConverter.class));
}