Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢捷峰
discovery
Commits
f6871877
Commit
f6871877
authored
Jul 28, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构类结构
parent
e962149a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
3 deletions
+21
-3
discovery-plugin-strategy/src/main/java/com/nepxion/discovery/plugin/strategy/configuration/StrategyAutoConfiguration.java
+5
-0
discovery-plugin-strategy/src/main/java/com/nepxion/discovery/plugin/strategy/discovery/DiscoveryEnabledAdapter.java
+4
-1
discovery-plugin-strategy/src/main/java/com/nepxion/discovery/plugin/strategy/discovery/DiscoveryEnabledPredicate.java
+12
-2
No files found.
discovery-plugin-strategy/src/main/java/com/nepxion/discovery/plugin/strategy/configuration/StrategyAutoConfiguration.java
View file @
f6871877
...
...
@@ -17,6 +17,7 @@ import org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
com.nepxion.discovery.plugin.framework.adapter.PluginAdapter
;
import
com.nepxion.discovery.plugin.strategy.constant.StrategyConstant
;
import
com.nepxion.discovery.plugin.strategy.discovery.DiscoveryEnabledAdapter
;
import
com.nepxion.discovery.plugin.strategy.discovery.DiscoveryEnabledPredicate
;
...
...
@@ -27,6 +28,9 @@ import com.nepxion.discovery.plugin.strategy.discovery.DiscoveryEnabledRule;
@ConditionalOnProperty
(
value
=
StrategyConstant
.
SPRING_APPLICATION_STRATEGY_CONTROL_ENABLED
,
matchIfMissing
=
true
)
public
class
StrategyAutoConfiguration
{
@Autowired
protected
PluginAdapter
pluginAdapter
;
@Autowired
private
DiscoveryEnabledAdapter
discoveryEnabledAdapter
;
@Bean
...
...
@@ -35,6 +39,7 @@ public class StrategyAutoConfiguration {
public
DiscoveryEnabledRule
discoveryEnabledRule
()
{
DiscoveryEnabledRule
discoveryEnabledRule
=
new
DiscoveryEnabledRule
();
DiscoveryEnabledPredicate
discoveryEnabledPredicate
=
discoveryEnabledRule
.
getDiscoveryEnabledPredicate
();
discoveryEnabledPredicate
.
setPluginAdapter
(
pluginAdapter
);
discoveryEnabledPredicate
.
setDiscoveryEnabledAdapter
(
discoveryEnabledAdapter
);
return
discoveryEnabledRule
;
...
...
discovery-plugin-strategy/src/main/java/com/nepxion/discovery/plugin/strategy/discovery/DiscoveryEnabledAdapter.java
View file @
f6871877
...
...
@@ -9,8 +9,10 @@ package com.nepxion.discovery.plugin.strategy.discovery;
* @version 1.0
*/
import
java.util.Map
;
import
com.netflix.loadbalancer.Server
;
public
interface
DiscoveryEnabledAdapter
{
boolean
apply
(
Server
server
);
boolean
apply
(
Server
server
,
Map
<
String
,
String
>
metadata
);
}
\ No newline at end of file
discovery-plugin-strategy/src/main/java/com/nepxion/discovery/plugin/strategy/discovery/DiscoveryEnabledPredicate.java
View file @
f6871877
...
...
@@ -9,12 +9,16 @@ package com.nepxion.discovery.plugin.strategy.discovery;
* @version 1.0
*/
import
java.util.Map
;
import
com.nepxion.discovery.plugin.framework.adapter.PluginAdapter
;
import
com.netflix.loadbalancer.AbstractServerPredicate
;
import
com.netflix.loadbalancer.PredicateKey
;
import
com.netflix.loadbalancer.Server
;
public
class
DiscoveryEnabledPredicate
extends
AbstractServerPredicate
{
private
DiscoveryEnabledAdapter
discoveryEnabledAdapter
;
protected
PluginAdapter
pluginAdapter
;
protected
DiscoveryEnabledAdapter
discoveryEnabledAdapter
;
@Override
public
boolean
apply
(
PredicateKey
input
)
{
...
...
@@ -22,7 +26,13 @@ public class DiscoveryEnabledPredicate extends AbstractServerPredicate {
}
protected
boolean
apply
(
Server
server
)
{
return
discoveryEnabledAdapter
.
apply
(
server
);
Map
<
String
,
String
>
metadata
=
pluginAdapter
.
getServerMetadata
(
server
);
return
discoveryEnabledAdapter
.
apply
(
server
,
metadata
);
}
public
void
setPluginAdapter
(
PluginAdapter
pluginAdapter
)
{
this
.
pluginAdapter
=
pluginAdapter
;
}
public
void
setDiscoveryEnabledAdapter
(
DiscoveryEnabledAdapter
discoveryEnabledAdapter
)
{
...
...
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