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
a903b5d5
Commit
a903b5d5
authored
Jun 24, 2015
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix guava imports
parent
25651f48
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
23 deletions
+25
-23
EurekaServerConfiguration.java
...loud/netflix/eureka/server/EurekaServerConfiguration.java
+25
-23
No files found.
spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfiguration.java
View file @
a903b5d5
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
package
org
.
springframework
.
cloud
.
netflix
.
eureka
.
server
;
package
org
.
springframework
.
cloud
.
netflix
.
eureka
.
server
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -42,8 +44,6 @@ import org.springframework.core.type.filter.AnnotationTypeFilter;
...
@@ -42,8 +44,6 @@ import org.springframework.core.type.filter.AnnotationTypeFilter;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Sets
;
import
com.sun.jersey.api.core.DefaultResourceConfig
;
import
com.sun.jersey.api.core.DefaultResourceConfig
;
import
com.sun.jersey.spi.container.servlet.ServletContainer
;
import
com.sun.jersey.spi.container.servlet.ServletContainer
;
...
@@ -58,11 +58,9 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
...
@@ -58,11 +58,9 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
/**
/**
* List of packages containing Jersey resources required by the Eureka server
* List of packages containing Jersey resources required by the Eureka server
*/
*/
private
static
String
[]
EUREKA_PACKAGES
=
new
String
[]
{
private
static
String
[]
EUREKA_PACKAGES
=
new
String
[]
{
"com.netflix.discovery"
,
"com.netflix.discovery"
,
"com.netflix.eureka"
};
"com.netflix.eureka"
};
@Bean
@Bean
@ConditionalOnProperty
(
prefix
=
"eureka.dashboard"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
@ConditionalOnProperty
(
prefix
=
"eureka.dashboard"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
public
EurekaController
eurekaController
()
{
public
EurekaController
eurekaController
()
{
...
@@ -71,18 +69,19 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
...
@@ -71,18 +69,19 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
/**
/**
* Register the Jersey filter
* Register the Jersey filter
*
*
* @param eurekaJerseyApp the jersey application
* @param eurekaJerseyApp the jersey application
* @return
* @return
*/
*/
@Bean
@Bean
public
FilterRegistrationBean
jerseyFilterRegistration
(
javax
.
ws
.
rs
.
core
.
Application
eurekaJerseyApp
)
{
public
FilterRegistrationBean
jerseyFilterRegistration
(
javax
.
ws
.
rs
.
core
.
Application
eurekaJerseyApp
)
{
FilterRegistrationBean
bean
=
new
FilterRegistrationBean
();
FilterRegistrationBean
bean
=
new
FilterRegistrationBean
();
bean
.
setFilter
(
new
ServletContainer
(
eurekaJerseyApp
));
bean
.
setFilter
(
new
ServletContainer
(
eurekaJerseyApp
));
bean
.
setOrder
(
Ordered
.
LOWEST_PRECEDENCE
);
bean
.
setOrder
(
Ordered
.
LOWEST_PRECEDENCE
);
bean
.
setUrlPatterns
(
Collections
bean
.
setUrlPatterns
(
Collections
.
singletonList
(
EurekaServerConfigBean
.
DEFAULT_PREFIX
+
"/*"
));
.
singletonList
(
EurekaServerConfigBean
.
DEFAULT_PREFIX
+
"/*"
));
return
bean
;
return
bean
;
}
}
...
@@ -91,40 +90,43 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
...
@@ -91,40 +90,43 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
* required by the Eureka server.
* required by the Eureka server.
*/
*/
@Bean
@Bean
public
javax
.
ws
.
rs
.
core
.
Application
jerseyApplication
(
Environment
environment
,
ResourceLoader
resourceLoader
)
{
public
javax
.
ws
.
rs
.
core
.
Application
jerseyApplication
(
Environment
environment
,
ResourceLoader
resourceLoader
)
{
ClassPathScanningCandidateComponentProvider
provider
=
new
ClassPathScanningCandidateComponentProvider
(
false
,
environment
);
ClassPathScanningCandidateComponentProvider
provider
=
new
ClassPathScanningCandidateComponentProvider
(
false
,
environment
);
// Filter to include only classes that have a particular annotation.
// Filter to include only classes that have a particular annotation.
//
//
provider
.
addIncludeFilter
(
new
AnnotationTypeFilter
(
Path
.
class
));
provider
.
addIncludeFilter
(
new
AnnotationTypeFilter
(
Path
.
class
));
provider
.
addIncludeFilter
(
new
AnnotationTypeFilter
(
Provider
.
class
));
provider
.
addIncludeFilter
(
new
AnnotationTypeFilter
(
Provider
.
class
));
// Find classes in Eureka packages (or subpackages)
// Find classes in Eureka packages (or subpackages)
//
//
Set
<
Class
<?>>
classes
=
Sets
.
newHashSet
();
Set
<
Class
<?>>
classes
=
new
HashSet
<
Class
<?>>
();
for
(
String
basePackage
:
EUREKA_PACKAGES
)
{
for
(
String
basePackage
:
EUREKA_PACKAGES
)
{
Set
<
BeanDefinition
>
beans
=
provider
.
findCandidateComponents
(
basePackage
);
Set
<
BeanDefinition
>
beans
=
provider
.
findCandidateComponents
(
basePackage
);
for
(
BeanDefinition
bd
:
beans
)
{
for
(
BeanDefinition
bd
:
beans
)
{
Class
<?>
cls
=
ClassUtils
.
resolveClassName
(
bd
.
getBeanClassName
(),
resourceLoader
.
getClassLoader
());
Class
<?>
cls
=
ClassUtils
.
resolveClassName
(
bd
.
getBeanClassName
(),
resourceLoader
.
getClassLoader
());
classes
.
add
(
cls
);
classes
.
add
(
cls
);
}
}
}
}
// Construct the Jersey ResourceConfig
// Construct the Jersey ResourceConfig
//
//
Map
<
String
,
Object
>
propsAndFeatures
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
propsAndFeatures
=
new
HashMap
<
String
,
Object
>
();
propsAndFeatures
.
put
(
propsAndFeatures
.
put
(
// Skip static content used by the webapp
// Skip static content used by the webapp
ServletContainer
.
PROPERTY_WEB_PAGE_CONTENT_REGEX
,
ServletContainer
.
PROPERTY_WEB_PAGE_CONTENT_REGEX
,
EurekaServerConfigBean
.
DEFAULT_PREFIX
+
"/(fonts|images|css|js)/.*"
);
EurekaServerConfigBean
.
DEFAULT_PREFIX
+
"/(fonts|images|css|js)/.*"
);
DefaultResourceConfig
rc
=
new
DefaultResourceConfig
(
classes
);
DefaultResourceConfig
rc
=
new
DefaultResourceConfig
(
classes
);
rc
.
setPropertiesAndFeatures
(
propsAndFeatures
);
rc
.
setPropertiesAndFeatures
(
propsAndFeatures
);
return
rc
;
return
rc
;
}
}
@Bean
@Bean
public
FilterRegistrationBean
traceFilterRegistration
(
public
FilterRegistrationBean
traceFilterRegistration
(
@Qualifier
(
"webRequestLoggingFilter"
)
Filter
filter
)
{
@Qualifier
(
"webRequestLoggingFilter"
)
Filter
filter
)
{
...
...
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