Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
5b149c7f
Commit
5b149c7f
authored
Jan 25, 2018
by
Taylor Wicksell
Committed by
Spencer Gibb
Jan 25, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do not rely on constructor injection in EurekaClientAutoConfiguration (#2670)
parent
35477d9c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
18 deletions
+12
-18
EurekaClientAutoConfiguration.java
...k/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
+12
-18
No files found.
spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
View file @
5b149c7f
...
...
@@ -94,16 +94,9 @@ import com.netflix.discovery.EurekaClientConfig;
"org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration"
})
public
class
EurekaClientAutoConfiguration
{
private
ConfigurableEnvironment
env
;
@Autowired
(
required
=
false
)
private
HealthCheckHandler
healthCheckHandler
;
private
RelaxedPropertyResolver
propertyResolver
;
public
EurekaClientAutoConfiguration
(
ConfigurableEnvironment
env
)
{
this
.
env
=
env
;
this
.
propertyResolver
=
new
RelaxedPropertyResolver
(
env
);
}
@Bean
public
HasFeatures
eurekaFeature
()
{
return
HasFeatures
.
namedFeature
(
"Eureka Client"
,
EurekaClient
.
class
);
...
...
@@ -111,9 +104,9 @@ public class EurekaClientAutoConfiguration {
@Bean
@ConditionalOnMissingBean
(
value
=
EurekaClientConfig
.
class
,
search
=
SearchStrategy
.
CURRENT
)
public
EurekaClientConfigBean
eurekaClientConfigBean
()
{
public
EurekaClientConfigBean
eurekaClientConfigBean
(
ConfigurableEnvironment
env
)
{
EurekaClientConfigBean
client
=
new
EurekaClientConfigBean
();
if
(
"bootstrap"
.
equals
(
propertyResolver
.
getProperty
(
"spring.config.name"
)))
{
if
(
"bootstrap"
.
equals
(
new
RelaxedPropertyResolver
(
env
)
.
getProperty
(
"spring.config.name"
)))
{
// We don't register during bootstrap by default, but there will be another
// chance later.
client
.
setRegisterWithEureka
(
false
);
...
...
@@ -130,23 +123,24 @@ public class EurekaClientAutoConfiguration {
@Bean
@ConditionalOnMissingBean
(
value
=
EurekaInstanceConfig
.
class
,
search
=
SearchStrategy
.
CURRENT
)
public
EurekaInstanceConfigBean
eurekaInstanceConfigBean
(
InetUtils
inetUtils
,
ManagementMetadataProvider
managementMetadataProvider
)
throws
MalformedURLException
{
PropertyResolver
eurekaPropertyResolver
=
new
RelaxedPropertyResolver
(
this
.
env
,
"eureka.instance."
);
ManagementMetadataProvider
managementMetadataProvider
,
ConfigurableEnvironment
env
)
throws
MalformedURLException
{
PropertyResolver
environmentPropertyResolver
=
new
RelaxedPropertyResolver
(
env
);
PropertyResolver
eurekaPropertyResolver
=
new
RelaxedPropertyResolver
(
env
,
"eureka.instance."
);
String
hostname
=
eurekaPropertyResolver
.
getProperty
(
"hostname"
);
boolean
preferIpAddress
=
Boolean
.
parseBoolean
(
eurekaPropertyResolver
.
getProperty
(
"preferIpAddress"
));
String
ipAddress
=
eurekaPropertyResolver
.
getProperty
(
"ipAddress"
);
boolean
isSecurePortEnabled
=
Boolean
.
parseBoolean
(
eurekaPropertyResolver
.
getProperty
(
"securePortEnabled"
));
String
serverContextPath
=
p
ropertyResolver
.
getProperty
(
"server.contextPath"
,
"/"
);
int
serverPort
=
Integer
.
valueOf
(
propertyResolver
.
getProperty
(
"server.port"
,
p
ropertyResolver
.
getProperty
(
"port"
,
"8080"
)));
String
serverContextPath
=
environmentP
ropertyResolver
.
getProperty
(
"server.contextPath"
,
"/"
);
int
serverPort
=
Integer
.
valueOf
(
environmentPropertyResolver
.
getProperty
(
"server.port"
,
environmentP
ropertyResolver
.
getProperty
(
"port"
,
"8080"
)));
Integer
managementPort
=
p
ropertyResolver
.
getProperty
(
"management.port"
,
Integer
.
class
);
// nullable. should be wrapped into optional
String
managementContextPath
=
p
ropertyResolver
.
getProperty
(
"management.contextPath"
);
// nullable. should be wrapped into optional
Integer
jmxPort
=
p
ropertyResolver
.
getProperty
(
"com.sun.management.jmxremote.port"
,
Integer
.
class
);
//nullable
Integer
managementPort
=
environmentP
ropertyResolver
.
getProperty
(
"management.port"
,
Integer
.
class
);
// nullable. should be wrapped into optional
String
managementContextPath
=
environmentP
ropertyResolver
.
getProperty
(
"management.contextPath"
);
// nullable. should be wrapped into optional
Integer
jmxPort
=
environmentP
ropertyResolver
.
getProperty
(
"com.sun.management.jmxremote.port"
,
Integer
.
class
);
//nullable
EurekaInstanceConfigBean
instance
=
new
EurekaInstanceConfigBean
(
inetUtils
);
instance
.
setNonSecurePort
(
serverPort
);
instance
.
setInstanceId
(
getDefaultInstanceId
(
p
ropertyResolver
));
instance
.
setInstanceId
(
getDefaultInstanceId
(
environmentP
ropertyResolver
));
instance
.
setPreferIpAddress
(
preferIpAddress
);
if
(
StringUtils
.
hasText
(
ipAddress
))
{
instance
.
setIpAddress
(
ipAddress
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment