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
db66e1c3
Unverified
Commit
db66e1c3
authored
Jan 08, 2018
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
polish
parent
113b49e2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
43 deletions
+40
-43
ConditionalOnRibbonAndEurekaEnabled.java
...ix/ribbon/eureka/ConditionalOnRibbonAndEurekaEnabled.java
+28
-6
RibbonEurekaAutoConfiguration.java
.../netflix/ribbon/eureka/RibbonEurekaAutoConfiguration.java
+0
-24
ConditionalOnRefreshScopeTests.java
.../cloud/netflix/eureka/ConditionalOnRefreshScopeTests.java
+12
-13
No files found.
spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/ribbon/eureka/ConditionalOnRibbonAndEurekaEnabled.java
View file @
db66e1c3
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
.
eureka
;
import
org.springframework.context.annotation.Conditional
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
* @author Igor Kryvenko
*/
import
org.springframework.boot.autoconfigure.condition.AllNestedConditions
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.context.annotation.Conditional
;
import
com.netflix.discovery.EurekaClient
;
import
com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
;
@Target
({
ElementType
.
TYPE
,
ElementType
.
METHOD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Conditional
(
RibbonEurekaAutoConfiguration
.
OnRibbonAndEurekaEnabledCondition
.
class
)
@Conditional
(
ConditionalOnRibbonAndEurekaEnabled
.
OnRibbonAndEurekaEnabledCondition
.
class
)
public
@interface
ConditionalOnRibbonAndEurekaEnabled
{
class
OnRibbonAndEurekaEnabledCondition
extends
AllNestedConditions
{
public
OnRibbonAndEurekaEnabledCondition
()
{
super
(
ConfigurationPhase
.
REGISTER_BEAN
);
}
@ConditionalOnClass
(
DiscoveryEnabledNIWSServerList
.
class
)
@ConditionalOnBean
(
SpringClientFactory
.
class
)
@ConditionalOnProperty
(
value
=
"ribbon.eureka.enabled"
,
matchIfMissing
=
true
)
static
class
Defaults
{}
@ConditionalOnBean
(
EurekaClient
.
class
)
static
class
EurekaBeans
{}
@ConditionalOnProperty
(
value
=
"eureka.client.enabled"
,
matchIfMissing
=
true
)
static
class
OnEurekaClientEnabled
{}
}
}
spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/ribbon/eureka/RibbonEurekaAutoConfiguration.java
View file @
db66e1c3
...
...
@@ -17,19 +17,11 @@
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
.
eureka
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.condition.AllNestedConditions
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration
;
import
org.springframework.cloud.netflix.ribbon.RibbonClients
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.context.annotation.Configuration
;
import
com.netflix.discovery.EurekaClient
;
import
com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
;
/**
* Spring configuration for configuring Ribbon defaults to be Eureka based
* if Eureka client is enabled
...
...
@@ -44,21 +36,5 @@ import com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList;
@RibbonClients
(
defaultConfiguration
=
EurekaRibbonClientConfiguration
.
class
)
public
class
RibbonEurekaAutoConfiguration
{
static
class
OnRibbonAndEurekaEnabledCondition
extends
AllNestedConditions
{
public
OnRibbonAndEurekaEnabledCondition
()
{
super
(
ConfigurationPhase
.
REGISTER_BEAN
);
}
@ConditionalOnClass
(
DiscoveryEnabledNIWSServerList
.
class
)
@ConditionalOnBean
(
SpringClientFactory
.
class
)
@ConditionalOnProperty
(
value
=
"ribbon.eureka.enabled"
,
matchIfMissing
=
true
)
static
class
Defaults
{}
@ConditionalOnBean
(
EurekaClient
.
class
)
static
class
EurekaBeans
{}
@ConditionalOnProperty
(
value
=
"eureka.client.enabled"
,
matchIfMissing
=
true
)
static
class
OnEurekaClientEnabled
{}
}
}
spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/ConditionalOnRefreshScopeTests.java
View file @
db66e1c3
...
...
@@ -20,15 +20,14 @@ import org.junit.After;
import
org.junit.Test
;
import
org.springframework.boot.Banner.Mode
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.test.context.assertj.AssertableApplicationContext
;
import
org.springframework.cloud.autoconfigure.RefreshAutoConfiguration
;
import
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration.ConditionalOnRefreshScope
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
springframework
.
boot
.
WebApplicationType
.
NONE
;
/**
* @author Dave Syer
...
...
@@ -36,7 +35,7 @@ import static org.junit.Assert.assertNotNull;
*/
public
class
ConditionalOnRefreshScopeTests
{
private
Configur
ableApplicationContext
context
;
private
Assert
ableApplicationContext
context
;
@After
public
void
close
()
{
...
...
@@ -47,18 +46,18 @@ public class ConditionalOnRefreshScopeTests {
@Test
public
void
refreshScopeIncluded
()
{
this
.
context
=
new
SpringApplicationBuilder
(
RefreshAutoConfiguration
.
class
,
Beans
.
class
).
web
(
false
).
bannerMode
(
Mode
.
OFF
).
run
(
);
assert
NotNull
(
this
.
context
.
get
Bean
(
org
.
springframework
.
cloud
.
context
.
scope
.
refresh
.
RefreshScope
.
class
)
)
;
assert
Equals
(
"foo"
,
this
.
context
.
getBean
(
"foo"
)
);
this
.
context
=
AssertableApplicationContext
.
get
(()
->
new
SpringApplicationBuilder
(
RefreshAutoConfiguration
.
class
,
Beans
.
class
).
web
(
NONE
).
bannerMode
(
Mode
.
OFF
).
run
()
);
assert
That
(
this
.
context
).
hasSingle
Bean
(
org
.
springframework
.
cloud
.
context
.
scope
.
refresh
.
RefreshScope
.
class
);
assert
That
(
this
.
context
).
getBean
(
"foo"
).
isEqualTo
(
"foo"
);
}
@Test
public
void
refreshScopeNotIncluded
()
{
this
.
context
=
new
SpringApplicationBuilder
(
Beans
.
class
).
web
(
false
)
.
bannerMode
(
Mode
.
OFF
).
run
();
assert
False
(
this
.
context
.
containsBean
(
"foo"
)
);
this
.
context
=
AssertableApplicationContext
.
get
(()
->
new
SpringApplicationBuilder
(
Beans
.
class
).
web
(
NONE
)
.
bannerMode
(
Mode
.
OFF
).
run
()
)
;
assert
That
(
this
.
context
).
doesNotHaveBean
(
"foo"
);
}
@Configuration
...
...
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