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
bcc9e135
Commit
bcc9e135
authored
Aug 21, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构策略模块
parent
5c9cd160
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
38 additions
and
32 deletions
+38
-32
discovery-plugin-strategy-extension-gateway/src/main/java/com/nepxion/discovery/plugin/strategy/extension/gateway/adapter/VersionDiscoveryEnabledAdapter.java
+5
-4
discovery-plugin-strategy-extension-service/src/main/java/com/nepxion/discovery/plugin/strategy/extension/service/adapter/VersionDiscoveryEnabledAdapter.java
+5
-4
discovery-plugin-strategy-extension-zuul/src/main/java/com/nepxion/discovery/plugin/strategy/extension/zuul/adapter/VersionDiscoveryEnabledAdapter.java
+5
-4
discovery-plugin-strategy/src/main/java/com/nepxion/discovery/plugin/strategy/adapter/DiscoveryEnabledStrategy.java
+3
-2
discovery-springcloud-example-gateway/src/main/java/com/nepxion/discovery/plugin/example/gateway/DiscoveryApplicationGateway.java
+3
-3
discovery-springcloud-example-gateway/src/main/java/com/nepxion/discovery/plugin/example/gateway/extension/MyDiscoveryEnabledStrategy.java
+3
-3
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationA1.java
+4
-3
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MyDiscoveryEnabledStrategy.java
+3
-3
discovery-springcloud-example-zuul/src/main/java/com/nepxion/discovery/plugin/example/zuul/DiscoveryApplicationZuul.java
+4
-3
discovery-springcloud-example-zuul/src/main/java/com/nepxion/discovery/plugin/example/zuul/extension/MyDiscoveryEnabledStrategy.java
+3
-3
No files found.
discovery-plugin-strategy-extension-gateway/src/main/java/com/nepxion/discovery/plugin/strategy/extension/gateway/adapter/VersionDiscoveryEnabledAdapter.java
View file @
bcc9e135
...
...
@@ -17,13 +17,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import
com.nepxion.discovery.common.constant.DiscoveryConstant
;
import
com.nepxion.discovery.common.util.JsonUtil
;
import
com.nepxion.discovery.plugin.strategy.adapter.DiscoveryEnabledAdapter
;
import
com.nepxion.discovery.plugin.strategy.
extension.DiscoveryEnabledExtension
;
import
com.nepxion.discovery.plugin.strategy.
adapter.DiscoveryEnabledStrategy
;
import
com.nepxion.discovery.plugin.strategy.extension.gateway.context.GatewayStrategyContext
;
import
com.netflix.loadbalancer.Server
;
public
class
VersionDiscoveryEnabledAdapter
implements
DiscoveryEnabledAdapter
{
@Autowired
(
required
=
false
)
private
DiscoveryEnabled
Extension
discoveryEnabledExtension
;
private
DiscoveryEnabled
Strategy
discoveryEnabledStrategy
;
@Override
public
boolean
apply
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
...
...
@@ -63,10 +63,10 @@ public class VersionDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
}
private
boolean
applyExtension
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
if
(
discoveryEnabled
Extension
==
null
)
{
if
(
discoveryEnabled
Strategy
==
null
)
{
return
true
;
}
return
discoveryEnabled
Extension
.
apply
(
server
,
metadata
);
return
discoveryEnabled
Strategy
.
apply
(
server
,
metadata
);
}
}
\ No newline at end of file
discovery-plugin-strategy-extension-service/src/main/java/com/nepxion/discovery/plugin/strategy/extension/service/adapter/VersionDiscoveryEnabledAdapter.java
View file @
bcc9e135
...
...
@@ -19,12 +19,12 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import
com.nepxion.discovery.common.constant.DiscoveryConstant
;
import
com.nepxion.discovery.common.util.JsonUtil
;
import
com.nepxion.discovery.plugin.strategy.adapter.DiscoveryEnabledAdapter
;
import
com.nepxion.discovery.plugin.strategy.
extension.DiscoveryEnabledExtension
;
import
com.nepxion.discovery.plugin.strategy.
adapter.DiscoveryEnabledStrategy
;
import
com.netflix.loadbalancer.Server
;
public
class
VersionDiscoveryEnabledAdapter
implements
DiscoveryEnabledAdapter
{
@Autowired
(
required
=
false
)
private
DiscoveryEnabled
Extension
discoveryEnabledExtension
;
private
DiscoveryEnabled
Strategy
discoveryEnabledStrategy
;
@Override
public
boolean
apply
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
...
...
@@ -68,10 +68,10 @@ public class VersionDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
}
private
boolean
applyExtension
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
if
(
discoveryEnabled
Extension
==
null
)
{
if
(
discoveryEnabled
Strategy
==
null
)
{
return
true
;
}
return
discoveryEnabled
Extension
.
apply
(
server
,
metadata
);
return
discoveryEnabled
Strategy
.
apply
(
server
,
metadata
);
}
}
\ No newline at end of file
discovery-plugin-strategy-extension-zuul/src/main/java/com/nepxion/discovery/plugin/strategy/extension/zuul/adapter/VersionDiscoveryEnabledAdapter.java
View file @
bcc9e135
...
...
@@ -17,13 +17,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import
com.nepxion.discovery.common.constant.DiscoveryConstant
;
import
com.nepxion.discovery.common.util.JsonUtil
;
import
com.nepxion.discovery.plugin.strategy.adapter.DiscoveryEnabledAdapter
;
import
com.nepxion.discovery.plugin.strategy.
extension.DiscoveryEnabledExtension
;
import
com.nepxion.discovery.plugin.strategy.
adapter.DiscoveryEnabledStrategy
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.zuul.context.RequestContext
;
public
class
VersionDiscoveryEnabledAdapter
implements
DiscoveryEnabledAdapter
{
@Autowired
(
required
=
false
)
private
DiscoveryEnabled
Extension
discoveryEnabledExtension
;
private
DiscoveryEnabled
Strategy
discoveryEnabledStrategy
;
@Override
public
boolean
apply
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
...
...
@@ -63,10 +63,10 @@ public class VersionDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
}
private
boolean
applyExtension
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
if
(
discoveryEnabled
Extension
==
null
)
{
if
(
discoveryEnabled
Strategy
==
null
)
{
return
true
;
}
return
discoveryEnabled
Extension
.
apply
(
server
,
metadata
);
return
discoveryEnabled
Strategy
.
apply
(
server
,
metadata
);
}
}
\ No newline at end of file
discovery-plugin-strategy/src/main/java/com/nepxion/discovery/plugin/strategy/
extension/DiscoveryEnabledExtension
.java
→
discovery-plugin-strategy/src/main/java/com/nepxion/discovery/plugin/strategy/
adapter/DiscoveryEnabledStrategy
.java
View file @
bcc9e135
package
com
.
nepxion
.
discovery
.
plugin
.
strategy
.
extension
;
package
com
.
nepxion
.
discovery
.
plugin
.
strategy
.
adapter
;
/**
* <p>Title: Nepxion Discovery</p>
...
...
@@ -13,6 +13,6 @@ import java.util.Map;
import
com.netflix.loadbalancer.Server
;
public
interface
DiscoveryEnabled
Extension
{
public
interface
DiscoveryEnabled
Strategy
{
boolean
apply
(
Server
server
,
Map
<
String
,
String
>
metadata
);
}
\ No newline at end of file
discovery-springcloud-example-gateway/src/main/java/com/nepxion/discovery/plugin/example/gateway/DiscoveryApplicationGateway.java
View file @
bcc9e135
...
...
@@ -14,7 +14,7 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.context.annotation.Bean
;
import
com.nepxion.discovery.plugin.example.gateway.extension.MyDiscoveryEnabled
Extension
;
import
com.nepxion.discovery.plugin.example.gateway.extension.MyDiscoveryEnabled
Strategy
;
@SpringBootApplication
@EnableDiscoveryClient
...
...
@@ -24,8 +24,8 @@ public class DiscoveryApplicationGateway {
}
@Bean
public
MyDiscoveryEnabled
Extension
myDiscoveryEnabledExtension
()
{
return
new
MyDiscoveryEnabled
Extension
();
public
MyDiscoveryEnabled
Strategy
myDiscoveryEnabledStrategy
()
{
return
new
MyDiscoveryEnabled
Strategy
();
}
/*@Bean
...
...
discovery-springcloud-example-gateway/src/main/java/com/nepxion/discovery/plugin/example/gateway/extension/MyDiscoveryEnabled
Extension
.java
→
discovery-springcloud-example-gateway/src/main/java/com/nepxion/discovery/plugin/example/gateway/extension/MyDiscoveryEnabled
Strategy
.java
View file @
bcc9e135
...
...
@@ -15,13 +15,13 @@ import org.apache.commons.lang3.StringUtils;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.nepxion.discovery.plugin.strategy.
extension.DiscoveryEnabledExtension
;
import
com.nepxion.discovery.plugin.strategy.
adapter.DiscoveryEnabledStrategy
;
import
com.nepxion.discovery.plugin.strategy.extension.gateway.context.GatewayStrategyContext
;
import
com.netflix.loadbalancer.Server
;
// 实现了组合策略,版本路由策略+自定义策略
public
class
MyDiscoveryEnabled
Extension
implements
DiscoveryEnabledExtension
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MyDiscoveryEnabled
Extension
.
class
);
public
class
MyDiscoveryEnabled
Strategy
implements
DiscoveryEnabledStrategy
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MyDiscoveryEnabled
Strategy
.
class
);
@Override
public
boolean
apply
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
...
...
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationA1.java
View file @
bcc9e135
...
...
@@ -18,7 +18,7 @@ import org.springframework.context.annotation.Bean;
import
com.nepxion.discovery.plugin.example.service.extension.MyDiscoveryListener
;
import
com.nepxion.discovery.plugin.example.service.extension.MyLoadBalanceListener
;
import
com.nepxion.discovery.plugin.example.service.extension.MyRegisterListener
;
import
com.nepxion.discovery.plugin.example.service.extension.MyDiscoveryEnabled
Extension
;
import
com.nepxion.discovery.plugin.example.service.extension.MyDiscoveryEnabled
Strategy
;
import
com.nepxion.discovery.plugin.example.service.extension.MySubscriber
;
@SpringBootApplication
...
...
@@ -52,7 +52,7 @@ public class DiscoveryApplicationA1 {
}
@Bean
public
MyDiscoveryEnabled
Extension
myDiscoveryEnabledExtension
()
{
return
new
MyDiscoveryEnabled
Extension
();
public
MyDiscoveryEnabled
Strategy
myDiscoveryEnabledStrategy
()
{
return
new
MyDiscoveryEnabled
Strategy
();
}
}
\ No newline at end of file
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MyDiscoveryEnabled
Extension
.java
→
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MyDiscoveryEnabled
Strategy
.java
View file @
bcc9e135
...
...
@@ -18,14 +18,14 @@ import org.springframework.web.context.request.RequestContextHolder;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
com.nepxion.discovery.common.constant.DiscoveryConstant
;
import
com.nepxion.discovery.plugin.strategy.
extension.DiscoveryEnabledExtension
;
import
com.nepxion.discovery.plugin.strategy.
adapter.DiscoveryEnabledStrategy
;
import
com.nepxion.discovery.plugin.strategy.extension.service.constant.ServiceStrategyConstant
;
import
com.nepxion.discovery.plugin.strategy.extension.service.context.ServiceStrategyContext
;
import
com.netflix.loadbalancer.Server
;
// 实现了组合策略,版本路由策略+自定义策略
public
class
MyDiscoveryEnabled
Extension
implements
DiscoveryEnabledExtension
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MyDiscoveryEnabled
Extension
.
class
);
public
class
MyDiscoveryEnabled
Strategy
implements
DiscoveryEnabledStrategy
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MyDiscoveryEnabled
Strategy
.
class
);
@Override
public
boolean
apply
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
...
...
discovery-springcloud-example-zuul/src/main/java/com/nepxion/discovery/plugin/example/zuul/DiscoveryApplicationZuul.java
View file @
bcc9e135
...
...
@@ -15,7 +15,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import
org.springframework.cloud.netflix.zuul.EnableZuulProxy
;
import
org.springframework.context.annotation.Bean
;
import
com.nepxion.discovery.plugin.example.zuul.extension.MyDiscoveryEnabled
Extension
;
import
com.nepxion.discovery.plugin.example.zuul.extension.MyDiscoveryEnabled
Strategy
;
@SpringBootApplication
@EnableDiscoveryClient
...
...
@@ -26,7 +26,7 @@ public class DiscoveryApplicationZuul {
}
@Bean
public
MyDiscoveryEnabled
Extension
myDiscoveryEnabledExtension
()
{
return
new
MyDiscoveryEnabled
Extension
();
public
MyDiscoveryEnabled
Strategy
myDiscoveryEnabledStrategy
()
{
return
new
MyDiscoveryEnabled
Strategy
();
}
}
\ No newline at end of file
discovery-springcloud-example-zuul/src/main/java/com/nepxion/discovery/plugin/example/zuul/extension/MyDiscoveryEnabled
Extension
.java
→
discovery-springcloud-example-zuul/src/main/java/com/nepxion/discovery/plugin/example/zuul/extension/MyDiscoveryEnabled
Strategy
.java
View file @
bcc9e135
...
...
@@ -15,13 +15,13 @@ import org.apache.commons.lang3.StringUtils;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.nepxion.discovery.plugin.strategy.
extension.DiscoveryEnabledExtension
;
import
com.nepxion.discovery.plugin.strategy.
adapter.DiscoveryEnabledStrategy
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.zuul.context.RequestContext
;
// 实现了组合策略,版本路由策略+自定义策略
public
class
MyDiscoveryEnabled
Extension
implements
DiscoveryEnabledExtension
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MyDiscoveryEnabled
Extension
.
class
);
public
class
MyDiscoveryEnabled
Strategy
implements
DiscoveryEnabledStrategy
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MyDiscoveryEnabled
Strategy
.
class
);
@Override
public
boolean
apply
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
...
...
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