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
b46dab30
Commit
b46dab30
authored
Jan 18, 2016
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put @Bean EurekaServerConfig in nested class to avoid cycle
A new integration test ill be added in spring-cloud-samples/tests. Fixes gh-759
parent
c97f6951
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
24 deletions
+26
-24
EurekaServerConfiguration.java
...loud/netflix/eureka/server/EurekaServerConfiguration.java
+26
-24
No files found.
spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfiguration.java
View file @
b46dab30
...
...
@@ -37,6 +37,7 @@ import org.springframework.boot.context.embedded.FilterRegistrationBean;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cloud.client.actuator.HasFeatures
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.netflix.eureka.EurekaConstants
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -72,9 +73,8 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
/**
* List of packages containing Jersey resources required by the Eureka server
*/
private
static
String
[]
EUREKA_PACKAGES
=
new
String
[]
{
"com.netflix.discovery"
,
"com.netflix.eureka"
};
private
static
String
[]
EUREKA_PACKAGES
=
new
String
[]
{
"com.netflix.discovery"
,
"com.netflix.eureka"
};
@Autowired
private
ApplicationInfoManager
applicationInfoManager
;
...
...
@@ -105,13 +105,16 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
return
HasFeatures
.
namedFeature
(
"Eureka Server"
,
EurekaServerConfiguration
.
class
);
}
@Configuration
protected
static
class
EurekaServerConfigBeanConfiguration
{
@Bean
@ConditionalOnMissingBean
public
EurekaServerConfig
eurekaServerConfig
()
{
return
new
EurekaServerConfigBean
();
}
}
//TODO: is there a better way?
//
TODO: is there a better way?
@Bean
(
name
=
"spring.http.encoding.CONFIGURATION_PROPERTIES"
)
public
HttpEncodingProperties
httpEncodingProperties
()
{
HttpEncodingProperties
properties
=
new
HttpEncodingProperties
();
...
...
@@ -122,48 +125,47 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
@Bean
@ConditionalOnProperty
(
prefix
=
"eureka.dashboard"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
public
EurekaController
eurekaController
()
{
return
new
EurekaController
(
applicationInfoManager
);
return
new
EurekaController
(
this
.
applicationInfoManager
);
}
@Bean
public
ServerCodecs
serverCodecs
()
{
return
new
DefaultServerCodecs
(
eurekaServerConfig
);
return
new
DefaultServerCodecs
(
this
.
eurekaServerConfig
);
}
@Bean
public
PeerAwareInstanceRegistry
peerAwareInstanceRegistry
(
ServerCodecs
serverCodecs
)
{
eurekaClient
.
getApplications
();
// force initialization
return
new
InstanceRegistry
(
eurekaServerConfig
,
eurekaClientConfig
,
serverCodecs
,
eurekaClient
,
expectedNumberOfRenewsPerMin
,
defaultOpenForTrafficCount
);
public
PeerAwareInstanceRegistry
peerAwareInstanceRegistry
(
ServerCodecs
serverCodecs
)
{
this
.
eurekaClient
.
getApplications
();
// force initialization
return
new
InstanceRegistry
(
this
.
eurekaServerConfig
,
this
.
eurekaClientConfig
,
serverCodecs
,
this
.
eurekaClient
,
this
.
expectedNumberOfRenewsPerMin
,
this
.
defaultOpenForTrafficCount
);
}
@Bean
public
PeerEurekaNodes
peerEurekaNodes
(
PeerAwareInstanceRegistry
registry
,
ServerCodecs
serverCodecs
)
{
return
new
PeerEurekaNodes
(
registry
,
eurekaServerConfig
,
eurekaClient
Config
,
serverCodecs
,
applicationInfoManager
);
return
new
PeerEurekaNodes
(
registry
,
this
.
eurekaServer
Config
,
this
.
eurekaClientConfig
,
serverCodecs
,
this
.
applicationInfoManager
);
}
@Bean
public
EurekaServerContext
eurekaServerContext
(
ServerCodecs
serverCodecs
,
PeerAwareInstanceRegistry
registry
,
PeerEurekaNodes
peerEurekaNodes
)
{
return
new
DefaultEurekaServerContext
(
eurekaServerConfig
,
serverCodecs
,
registry
,
peerEurekaNodes
,
applicationInfoManager
);
PeerAwareInstanceRegistry
registry
,
PeerEurekaNodes
peerEurekaNodes
)
{
return
new
DefaultEurekaServerContext
(
this
.
eurekaServerConfig
,
serverCodecs
,
registry
,
peerEurekaNodes
,
this
.
applicationInfoManager
);
}
@Bean
public
EurekaServerBootstrap
eurekaServerBootstrap
(
PeerAwareInstanceRegistry
registry
,
EurekaServerContext
serverContext
)
{
return
new
EurekaServerBootstrap
(
applicationInfoManager
,
eurekaClientConfig
,
eurekaServerConfig
,
registry
,
serverContext
);
return
new
EurekaServerBootstrap
(
this
.
applicationInfoManager
,
this
.
eurekaClientConfig
,
this
.
eurekaServerConfig
,
registry
,
serverContext
);
}
/**
* Register the Jersey filter
*
* @param eurekaJerseyApp the jersey application
* @return
*/
@Bean
public
FilterRegistrationBean
jerseyFilterRegistration
(
...
...
@@ -171,8 +173,8 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
FilterRegistrationBean
bean
=
new
FilterRegistrationBean
();
bean
.
setFilter
(
new
ServletContainer
(
eurekaJerseyApp
));
bean
.
setOrder
(
Ordered
.
LOWEST_PRECEDENCE
);
bean
.
setUrlPatterns
(
Collections
.
singletonList
(
EurekaServerConfigBean
.
DEFAULT_PREFIX
+
"/*"
));
bean
.
setUrlPatterns
(
Collections
.
singletonList
(
EurekaConstants
.
DEFAULT_PREFIX
+
"/*"
));
return
bean
;
}
...
...
@@ -211,7 +213,7 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
propsAndFeatures
.
put
(
// Skip static content used by the webapp
ServletContainer
.
PROPERTY_WEB_PAGE_CONTENT_REGEX
,
Eureka
ServerConfigBean
.
DEFAULT_PREFIX
+
"/(fonts|images|css|js)/.*"
);
Eureka
Constants
.
DEFAULT_PREFIX
+
"/(fonts|images|css|js)/.*"
);
DefaultResourceConfig
rc
=
new
DefaultResourceConfig
(
classes
);
rc
.
setPropertiesAndFeatures
(
propsAndFeatures
);
...
...
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