Commit 50efa853 by Spencer Gibb

add optional DiscoveryClientOptionalArgs

For extensibility by connectors
parent 966e03ba
...@@ -16,11 +16,14 @@ ...@@ -16,11 +16,14 @@
package org.springframework.cloud.netflix.eureka; package org.springframework.cloud.netflix.eureka;
import com.netflix.appinfo.ApplicationInfoManager; import java.lang.annotation.Documented;
import com.netflix.appinfo.EurekaInstanceConfig; import java.lang.annotation.ElementType;
import com.netflix.discovery.EurekaClient; import java.lang.annotation.Retention;
import com.netflix.discovery.EurekaClientConfig; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.AllNestedConditions; import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
...@@ -36,11 +39,11 @@ import org.springframework.context.annotation.Bean; ...@@ -36,11 +39,11 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.lang.annotation.Documented; import com.netflix.appinfo.ApplicationInfoManager;
import java.lang.annotation.ElementType; import com.netflix.appinfo.EurekaInstanceConfig;
import java.lang.annotation.Retention; import com.netflix.discovery.DiscoveryClient.DiscoveryClientOptionalArgs;
import java.lang.annotation.RetentionPolicy; import com.netflix.discovery.EurekaClient;
import java.lang.annotation.Target; import com.netflix.discovery.EurekaClientConfig;
/** /**
* @author Spencer Gibb * @author Spencer Gibb
...@@ -61,13 +64,16 @@ public class DiscoveryClientConfiguration { ...@@ -61,13 +64,16 @@ public class DiscoveryClientConfiguration {
@Autowired @Autowired
private ApplicationContext context; private ApplicationContext context;
@Autowired(required = false)
private DiscoveryClientOptionalArgs optionalArgs;
@Bean(destroyMethod = "shutdown") @Bean(destroyMethod = "shutdown")
@ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT) @ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT)
@SneakyThrows @SneakyThrows
public EurekaClient eurekaClient(ApplicationInfoManager applicationInfoManager, public EurekaClient eurekaClient(ApplicationInfoManager applicationInfoManager,
EurekaClientConfig config, EurekaInstanceConfig instance) { EurekaClientConfig config, EurekaInstanceConfig instance) {
applicationInfoManager.initComponent(instance); applicationInfoManager.initComponent(instance);
return new CloudEurekaClient(applicationInfoManager, config, this.context); return new CloudEurekaClient(applicationInfoManager, config, optionalArgs, this.context);
} }
} }
...@@ -78,6 +84,9 @@ public class DiscoveryClientConfiguration { ...@@ -78,6 +84,9 @@ public class DiscoveryClientConfiguration {
@Autowired @Autowired
private ApplicationContext context; private ApplicationContext context;
@Autowired(required = false)
private DiscoveryClientOptionalArgs optionalArgs;
@Bean(destroyMethod = "shutdown") @Bean(destroyMethod = "shutdown")
@ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT) @ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT)
@SneakyThrows @SneakyThrows
...@@ -85,7 +94,7 @@ public class DiscoveryClientConfiguration { ...@@ -85,7 +94,7 @@ public class DiscoveryClientConfiguration {
public EurekaClient eurekaClient(ApplicationInfoManager applicationInfoManager, public EurekaClient eurekaClient(ApplicationInfoManager applicationInfoManager,
EurekaClientConfig config, EurekaInstanceConfig instance) { EurekaClientConfig config, EurekaInstanceConfig instance) {
applicationInfoManager.initComponent(instance); applicationInfoManager.initComponent(instance);
return new CloudEurekaClient(applicationInfoManager, config, this.context); return new CloudEurekaClient(applicationInfoManager, config, optionalArgs, this.context);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment