org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties Java Examples

The following examples show how to use org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConsulAutoRegistration.java    From spring-cloud-consul with Apache License 2.0 7 votes vote down vote up
public static ConsulAutoRegistration managementRegistration(
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties, ApplicationContext context,
		List<ConsulManagementRegistrationCustomizer> managementRegistrationCustomizers,
		HeartbeatProperties heartbeatProperties) {
	NewService management = new NewService();
	management.setId(getManagementServiceId(properties, context));
	management.setAddress(properties.getHostname());
	management
			.setName(getManagementServiceName(properties, context.getEnvironment()));
	management.setPort(getManagementPort(properties, context));
	management.setTags(properties.getManagementTags());
	management.setEnableTagOverride(properties.getManagementEnableTagOverride());
	management.setMeta(properties.getManagementMetadata());
	if (properties.isRegisterHealthCheck()) {
		management.setCheck(createCheck(getManagementPort(properties, context),
				heartbeatProperties, properties));
	}
	ConsulAutoRegistration registration = new ConsulAutoRegistration(management,
			autoServiceRegistrationProperties, properties, context,
			heartbeatProperties, managementRegistrationCustomizers);
	managementCustomize(managementRegistrationCustomizers, registration);
	return registration;
}
 
Example #2
Source File: ConsulAutoRegistration.java    From spring-cloud-consul with Apache License 2.0 7 votes vote down vote up
public static void setCheck(NewService service,
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties, ApplicationContext context,
		HeartbeatProperties heartbeatProperties) {
	if (properties.isRegisterHealthCheck() && service.getCheck() == null) {
		Integer checkPort;
		if (shouldRegisterManagement(autoServiceRegistrationProperties, properties,
				context)) {
			checkPort = getManagementPort(properties, context);
		}
		else {
			checkPort = service.getPort();
		}
		Assert.notNull(checkPort, "checkPort may not be null");
		service.setCheck(createCheck(checkPort, heartbeatProperties, properties));
	}
}
 
Example #3
Source File: SidecarConsulAutoRegistration.java    From spring-cloud-alibaba with Apache License 2.0 6 votes vote down vote up
public SidecarConsulAutoRegistration(NewService service,
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties, ApplicationContext context,
		HeartbeatProperties heartbeatProperties,
		List<ConsulManagementRegistrationCustomizer> managementRegistrationCustomizers) {
	super(service, autoServiceRegistrationProperties, properties, context,
			heartbeatProperties, managementRegistrationCustomizers);
}
 
Example #4
Source File: ConsulLightminClientDiscoveryConfiguration.java    From spring-batch-lightmin with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean(ConsulAutoRegistration.class)
public ConsulAutoRegistration consulAutoRegistration(
        final MetaDataExtender metaDataExtender,
        final AutoServiceRegistrationProperties autoServiceRegistrationProperties,
        final ConsulDiscoveryProperties consulDiscoveryProperties,
        final ApplicationContext applicationContext,
        final List<ConsulRegistrationCustomizer> consulRegistrationCustomizers,
        final List<ConsulManagementRegistrationCustomizer> managementRegistrationCustomizers,
        final HeartbeatProperties heartbeatProperties) {

    metaDataExtender.extendMetaData();
    return ConsulAutoRegistration.registration(
            autoServiceRegistrationProperties,
            consulDiscoveryProperties,
            applicationContext,
            consulRegistrationCustomizers,
            managementRegistrationCustomizers,
            heartbeatProperties);
}
 
Example #5
Source File: ConsulAutoRegistration.java    From spring-cloud-consul with Apache License 2.0 6 votes vote down vote up
public ConsulAutoRegistration(NewService service,
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties, ApplicationContext context,
		HeartbeatProperties heartbeatProperties,
		List<ConsulManagementRegistrationCustomizer> managementRegistrationCustomizers) {
	super(service, properties);
	this.autoServiceRegistrationProperties = autoServiceRegistrationProperties;
	this.context = context;
	this.heartbeatProperties = heartbeatProperties;
	this.managementRegistrationCustomizers = managementRegistrationCustomizers;
}
 
Example #6
Source File: ConsulAutoRegistration.java    From spring-cloud-consul with Apache License 2.0 6 votes vote down vote up
@Deprecated
public ConsulAutoRegistration(NewService service,
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties, ApplicationContext context,
		HeartbeatProperties heartbeatProperties) {
	this(service, autoServiceRegistrationProperties, properties, context,
			heartbeatProperties, Collections.emptyList());
}
 
Example #7
Source File: EurekaClientAutoConfiguration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnBean(AutoServiceRegistrationProperties.class)
@ConditionalOnProperty(
		value = "spring.cloud.service-registry.auto-registration.enabled",
		matchIfMissing = true)
public EurekaRegistration eurekaRegistration(EurekaClient eurekaClient,
		CloudEurekaInstanceConfig instanceConfig,
		ApplicationInfoManager applicationInfoManager, @Autowired(
				required = false) ObjectProvider<HealthCheckHandler> healthCheckHandler) {
	return EurekaRegistration.builder(instanceConfig).with(applicationInfoManager)
			.with(eurekaClient).with(healthCheckHandler).build();
}
 
Example #8
Source File: ConsulAutoServiceRegistrationCustomizedTests.java    From spring-cloud-consul with Apache License 2.0 5 votes vote down vote up
@Autowired
public CustomAutoRegistration(ConsulServiceRegistry serviceRegistry,
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties,
		ConsulAutoRegistration registration) {
	super(serviceRegistry, autoServiceRegistrationProperties, properties,
			registration);
}
 
Example #9
Source File: ConsulAutoServiceRegistrationCustomizedTests.java    From spring-cloud-consul with Apache License 2.0 5 votes vote down vote up
@Bean
public CustomAutoRegistration consulAutoServiceRegistration(
		ConsulServiceRegistry serviceRegistry,
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties,
		ConsulAutoRegistration registration) {
	return new CustomAutoRegistration(serviceRegistry,
			autoServiceRegistrationProperties, properties, registration);
}
 
Example #10
Source File: ConsulAutoServiceRegistrationAutoConfiguration.java    From spring-cloud-consul with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public ConsulAutoRegistration consulRegistration(
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties, ApplicationContext applicationContext,
		ObjectProvider<List<ConsulRegistrationCustomizer>> registrationCustomizers,
		ObjectProvider<List<ConsulManagementRegistrationCustomizer>> managementRegistrationCustomizers,
		HeartbeatProperties heartbeatProperties) {
	return ConsulAutoRegistration.registration(autoServiceRegistrationProperties,
			properties, applicationContext, registrationCustomizers.getIfAvailable(),
			managementRegistrationCustomizers.getIfAvailable(), heartbeatProperties);
}
 
Example #11
Source File: ConsulAutoServiceRegistrationAutoConfiguration.java    From spring-cloud-consul with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public ConsulAutoServiceRegistration consulAutoServiceRegistration(
		ConsulServiceRegistry registry,
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties,
		ConsulAutoRegistration consulRegistration) {
	return new ConsulAutoServiceRegistration(registry,
			autoServiceRegistrationProperties, properties, consulRegistration);
}
 
Example #12
Source File: ConsulAutoServiceRegistration.java    From spring-cloud-consul with Apache License 2.0 5 votes vote down vote up
public ConsulAutoServiceRegistration(ConsulServiceRegistry serviceRegistry,
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties, ConsulAutoRegistration registration) {
	super(serviceRegistry, autoServiceRegistrationProperties);
	this.properties = properties;
	this.registration = registration;
}
 
Example #13
Source File: ConsulAutoRegistration.java    From spring-cloud-consul with Apache License 2.0 5 votes vote down vote up
/**
 * @param autoServiceRegistrationProperties registration properties
 * @param properties discovery properties
 * @param context Spring application context
 * @return if the management service should be registered with the
 * {@link ServiceRegistry}
 */
public static boolean shouldRegisterManagement(
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties, ApplicationContext context) {
	return autoServiceRegistrationProperties.isRegisterManagement()
			&& getManagementPort(properties, context) != null
			&& ManagementServerPortUtils.isDifferent(context);
}
 
Example #14
Source File: EurekaClientAutoConfiguration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Bean
@org.springframework.cloud.context.config.annotation.RefreshScope
@ConditionalOnBean(AutoServiceRegistrationProperties.class)
@ConditionalOnProperty(
		value = "spring.cloud.service-registry.auto-registration.enabled",
		matchIfMissing = true)
public EurekaRegistration eurekaRegistration(EurekaClient eurekaClient,
		CloudEurekaInstanceConfig instanceConfig,
		ApplicationInfoManager applicationInfoManager, @Autowired(
				required = false) ObjectProvider<HealthCheckHandler> healthCheckHandler) {
	return EurekaRegistration.builder(instanceConfig).with(applicationInfoManager)
			.with(eurekaClient).with(healthCheckHandler).build();
}
 
Example #15
Source File: EurekaClientAutoConfiguration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnBean(AutoServiceRegistrationProperties.class)
@ConditionalOnProperty(
		value = "spring.cloud.service-registry.auto-registration.enabled",
		matchIfMissing = true)
public EurekaAutoServiceRegistration eurekaAutoServiceRegistration(
		ApplicationContext context, EurekaServiceRegistry registry,
		EurekaRegistration registration) {
	return new EurekaAutoServiceRegistration(context, registry, registration);
}
 
Example #16
Source File: ZookeeperAutoServiceRegistration.java    From spring-cloud-zookeeper with Apache License 2.0 5 votes vote down vote up
public ZookeeperAutoServiceRegistration(ZookeeperServiceRegistry registry,
		ZookeeperRegistration registration, ZookeeperDiscoveryProperties properties,
		AutoServiceRegistrationProperties arProperties) {
	super(registry, arProperties);
	this.registration = registration;
	this.properties = properties;
	if (this.properties.getInstancePort() != null) {
		this.registration.setPort(this.properties.getInstancePort());
	}
}
 
Example #17
Source File: NacosServiceRegistryAutoConfiguration.java    From spring-cloud-alibaba with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnBean(AutoServiceRegistrationProperties.class)
public NacosAutoServiceRegistration nacosAutoServiceRegistration(
		NacosServiceRegistry registry,
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		NacosRegistration registration) {
	return new NacosAutoServiceRegistration(registry,
			autoServiceRegistrationProperties, registration);
}
 
Example #18
Source File: NacosServiceRegistryAutoConfiguration.java    From spring-cloud-alibaba with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnBean(AutoServiceRegistrationProperties.class)
public NacosRegistration nacosRegistration(
		NacosDiscoveryProperties nacosDiscoveryProperties,
		ApplicationContext context) {
	return new NacosRegistration(nacosDiscoveryProperties, context);
}
 
Example #19
Source File: SidecarConsulAutoConfiguration.java    From spring-cloud-alibaba with Apache License 2.0 5 votes vote down vote up
@Bean
public ConsulAutoRegistration consulRegistration(
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		ConsulDiscoveryProperties properties, ApplicationContext applicationContext,
		ObjectProvider<List<ConsulRegistrationCustomizer>> registrationCustomizers,
		ObjectProvider<List<ConsulManagementRegistrationCustomizer>> managementRegistrationCustomizers,
		HeartbeatProperties heartbeatProperties,
		SidecarProperties sidecarProperties) {
	return SidecarConsulAutoRegistration.registration(
			autoServiceRegistrationProperties, properties, applicationContext,
			registrationCustomizers.getIfAvailable(),
			managementRegistrationCustomizers.getIfAvailable(), heartbeatProperties,
			sidecarProperties);
}
 
Example #20
Source File: ServiceCombRegistryAutoConfiguration.java    From spring-cloud-huawei with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnBean(AutoServiceRegistrationProperties.class)
public ServiceCombAutoServiceRegistration serviceCombAutoServiceRegistration(
    ServiceCombServiceRegistry registry,
    AutoServiceRegistrationProperties autoServiceRegistrationProperties,
    ServiceCombRegistration registration) {
  return new ServiceCombAutoServiceRegistration(registry,
      autoServiceRegistrationProperties, registration);
}
 
Example #21
Source File: ServiceCombAutoServiceRegistration.java    From spring-cloud-huawei with Apache License 2.0 4 votes vote down vote up
public ServiceCombAutoServiceRegistration(ServiceCombServiceRegistry registry,
    AutoServiceRegistrationProperties autoServiceRegistrationProperties, ServiceCombRegistration registration) {
  super(registry, autoServiceRegistrationProperties);
  this.serviceCombRegistration = registration;
}
 
Example #22
Source File: NacosAutoServiceRegistration.java    From spring-cloud-alibaba with Apache License 2.0 4 votes vote down vote up
public NacosAutoServiceRegistration(ServiceRegistry<Registration> serviceRegistry,
		AutoServiceRegistrationProperties autoServiceRegistrationProperties,
		NacosRegistration registration) {
	super(serviceRegistry, autoServiceRegistrationProperties);
	this.registration = registration;
}
 
Example #23
Source File: MossNacosAutoServiceRegistration.java    From Moss with Apache License 2.0 4 votes vote down vote up
public MossNacosAutoServiceRegistration(ServiceRegistry<NacosRegistration> serviceRegistry,
                                        AutoServiceRegistrationProperties autoServiceRegistrationProperties, NacosRegistration registration, NacosRegistration registration1) {
    super(serviceRegistry, autoServiceRegistrationProperties, registration);
    this.registration = registration1;
}
 
Example #24
Source File: ServiceCombRegistryAutoConfiguration.java    From spring-cloud-huawei with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnBean(AutoServiceRegistrationProperties.class)
public ServiceCombRegistration serviceCombRegistration(
    ServiceCombDiscoveryProperties serviceCombDiscoveryProperties) {
  return new ServiceCombRegistration(serviceCombDiscoveryProperties);
}