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
9744aa1a
Commit
9744aa1a
authored
Jul 27, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构类结构
parent
35a6063c
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
101 additions
and
38 deletions
+101
-38
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationA1.java
+9
-8
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationA2.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationB1.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationB2.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationC1.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationC2.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/DiscoveryApplicationC3.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MyDiscoveryListener.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MyLoadBalanceListener.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MyRegisterListener.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MyServiceDiscoveryEnabledAdapter.java
+14
-11
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MySubscriber.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/feign/AFeign.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/feign/AFeignImpl.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/feign/AbstractFeignImpl.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/feign/BFeign.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/feign/BFeignImpl.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/feign/CFeign.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/feign/CFeignImpl.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/service/feign/FeignConfiguration.java
+1
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/zuul/DiscoveryApplicationZuul.java
+10
-1
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/zuul/extension/MyZuulDiscoveryEnabledAdapter.java
+50
-0
No files found.
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/DiscoveryApplicationA1.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
DiscoveryApplicationA1.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
@@ -15,11 +15,11 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
...
@@ -15,11 +15,11 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
com.nepxion.discovery.plugin.example.
extension.MyDiscoveryEnabledAdapt
er
;
import
com.nepxion.discovery.plugin.example.
service.extension.MyDiscoveryListen
er
;
import
com.nepxion.discovery.plugin.example.
extension.MyDiscovery
Listener
;
import
com.nepxion.discovery.plugin.example.
service.extension.MyLoadBalance
Listener
;
import
com.nepxion.discovery.plugin.example.
extension.MyLoadBalance
Listener
;
import
com.nepxion.discovery.plugin.example.
service.extension.MyRegister
Listener
;
import
com.nepxion.discovery.plugin.example.
extension.MyRegisterListen
er
;
import
com.nepxion.discovery.plugin.example.
service.extension.MyServiceDiscoveryEnabledAdapt
er
;
import
com.nepxion.discovery.plugin.example.extension.MySubscriber
;
import
com.nepxion.discovery.plugin.example.
service.
extension.MySubscriber
;
@SpringBootApplication
@SpringBootApplication
@EnableDiscoveryClient
@EnableDiscoveryClient
...
@@ -52,7 +52,7 @@ public class DiscoveryApplicationA1 {
...
@@ -52,7 +52,7 @@ public class DiscoveryApplicationA1 {
}
}
@Bean
@Bean
public
My
DiscoveryEnabledAdapter
My
DiscoveryEnabledAdapter
()
{
public
My
ServiceDiscoveryEnabledAdapter
myService
DiscoveryEnabledAdapter
()
{
return
new
MyDiscoveryEnabledAdapter
();
return
new
My
Service
DiscoveryEnabledAdapter
();
}
}
}
}
\ No newline at end of file
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/DiscoveryApplicationA2.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
DiscoveryApplicationA2.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/DiscoveryApplicationB1.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
DiscoveryApplicationB1.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/DiscoveryApplicationB2.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
DiscoveryApplicationB2.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/DiscoveryApplicationC1.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
DiscoveryApplicationC1.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/DiscoveryApplicationC2.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
DiscoveryApplicationC2.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/DiscoveryApplicationC3.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
DiscoveryApplicationC3.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/extension/MyDiscoveryListener.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
extension/MyDiscoveryListener.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
extension
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
.
extension
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/extension/MyLoadBalanceListener.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
extension/MyLoadBalanceListener.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
extension
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
.
extension
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/extension/MyRegisterListener.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
extension/MyRegisterListener.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
extension
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
.
extension
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
extension/My
DiscoveryEnabledAdapter.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/extension/MyService
DiscoveryEnabledAdapter.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
extension
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
.
extension
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
@@ -16,28 +16,31 @@ import org.slf4j.LoggerFactory;
...
@@ -16,28 +16,31 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.nepxion.discovery.plugin.framework.adapter.PluginAdapter
;
import
com.nepxion.discovery.plugin.framework.adapter.PluginAdapter
;
import
com.nepxion.discovery.plugin.strategy.extension.constant.StrategyConstant
;
import
com.nepxion.discovery.plugin.strategy.discovery.DiscoveryEnabledAdapter
;
import
com.nepxion.discovery.plugin.strategy.extension.context.StrategyContext
;
import
com.nepxion.discovery.plugin.strategy.extension.service.constant.ServiceStrategyConstant
;
import
com.nepxion.discovery.plugin.strategy.extension.enable.DiscoveryEnabledAdapter
;
import
com.nepxion.discovery.plugin.strategy.extension.service.context.ServiceStrategyContext
;
import
com.nepxion.discovery.plugin.strategy.extension.service.context.ServiceStrategyContextHolder
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.loadbalancer.Server
;
public
class
MyDiscoveryEnabledAdapter
implements
DiscoveryEnabledAdapter
{
public
class
My
Service
DiscoveryEnabledAdapter
implements
DiscoveryEnabledAdapter
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MyDiscoveryEnabledAdapter
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
My
Service
DiscoveryEnabledAdapter
.
class
);
@Autowired
@Autowired
protected
PluginAdapter
pluginAdapter
;
protected
PluginAdapter
pluginAdapter
;
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
@Override
@Override
public
boolean
apply
(
Server
server
,
StrategyContext
context
)
{
public
boolean
apply
(
Server
server
)
{
ServiceStrategyContext
context
=
ServiceStrategyContextHolder
.
currentContext
();
Map
<
String
,
Object
>
attributes
=
context
.
getAttributes
();
String
serviceId
=
server
.
getMetaInfo
().
getAppName
().
toLowerCase
();
String
serviceId
=
server
.
getMetaInfo
().
getAppName
().
toLowerCase
();
Map
<
String
,
String
>
metadata
=
pluginAdapter
.
getServerMetadata
(
server
);
Map
<
String
,
String
>
metadata
=
pluginAdapter
.
getServerMetadata
(
server
);
Map
<
String
,
Object
>
attributes
=
context
.
getAttributes
();
LOG
.
info
(
"负载均衡用户定制触发:serviceId={}, host={}, metadata={}, context={}"
,
serviceId
,
server
.
toString
(),
metadata
,
context
);
LOG
.
info
(
"
Serivice端
负载均衡用户定制触发:serviceId={}, host={}, metadata={}, context={}"
,
serviceId
,
server
.
toString
(),
metadata
,
context
);
if
(
attributes
.
containsKey
(
StrategyConstant
.
PARAMETER_MAP
))
{
if
(
attributes
.
containsKey
(
S
erviceS
trategyConstant
.
PARAMETER_MAP
))
{
Map
<
String
,
Object
>
parameterMap
=
(
Map
<
String
,
Object
>)
attributes
.
get
(
StrategyConstant
.
PARAMETER_MAP
);
Map
<
String
,
Object
>
parameterMap
=
(
Map
<
String
,
Object
>)
attributes
.
get
(
S
erviceS
trategyConstant
.
PARAMETER_MAP
);
String
value
=
parameterMap
.
get
(
"value"
).
toString
();
String
value
=
parameterMap
.
get
(
"value"
).
toString
();
if
(
value
.
contains
(
"abc"
))
{
if
(
value
.
contains
(
"abc"
))
{
LOG
.
info
(
"过滤条件:当前端输入值包含'abc'的时候,不能被Ribbon负载均衡到"
);
LOG
.
info
(
"过滤条件:当前端输入值包含'abc'的时候,不能被Ribbon负载均衡到"
);
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/extension/MySubscriber.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
extension/MySubscriber.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
extension
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
.
extension
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/feign/AFeign.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
feign/AFeign.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
feign
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
.
feign
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/feign/AFeignImpl.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
feign/AFeignImpl.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
feign
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
.
feign
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/feign/AbstractFeignImpl.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
feign/AbstractFeignImpl.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
feign
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
.
feign
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/feign/BFeign.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
feign/BFeign.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
feign
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
.
feign
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/feign/BFeignImpl.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
feign/BFeignImpl.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
feign
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
.
feign
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/feign/CFeign.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
feign/CFeign.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
feign
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
.
feign
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/feign/CFeignImpl.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
feign/CFeignImpl.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
feign
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
.
feign
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/feign/FeignConfiguration.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
service/
feign/FeignConfiguration.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
feign
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
service
.
feign
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
...
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/DiscoveryApplicationZuul.java
→
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/
zuul/
DiscoveryApplicationZuul.java
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
;
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
zuul
;
/**
/**
* <p>Title: Nepxion Discovery</p>
* <p>Title: Nepxion Discovery</p>
...
@@ -13,6 +13,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
...
@@ -13,6 +13,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.netflix.zuul.EnableZuulProxy
;
import
org.springframework.cloud.netflix.zuul.EnableZuulProxy
;
import
org.springframework.context.annotation.Bean
;
import
com.nepxion.discovery.plugin.example.zuul.extension.MyZuulDiscoveryEnabledAdapter
;
@SpringBootApplication
@SpringBootApplication
@EnableDiscoveryClient
@EnableDiscoveryClient
...
@@ -23,4 +26,9 @@ public class DiscoveryApplicationZuul {
...
@@ -23,4 +26,9 @@ public class DiscoveryApplicationZuul {
new
SpringApplicationBuilder
(
DiscoveryApplicationZuul
.
class
).
run
(
args
);
new
SpringApplicationBuilder
(
DiscoveryApplicationZuul
.
class
).
run
(
args
);
}
}
@Bean
public
MyZuulDiscoveryEnabledAdapter
myZuulDiscoveryEnabledAdapter
()
{
return
new
MyZuulDiscoveryEnabledAdapter
();
}
}
}
\ No newline at end of file
discovery-springcloud-example/src/main/java/com/nepxion/discovery/plugin/example/zuul/extension/MyZuulDiscoveryEnabledAdapter.java
0 → 100644
View file @
9744aa1a
package
com
.
nepxion
.
discovery
.
plugin
.
example
.
zuul
.
extension
;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.nepxion.discovery.plugin.framework.adapter.PluginAdapter
;
import
com.nepxion.discovery.plugin.strategy.discovery.DiscoveryEnabledAdapter
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.zuul.context.RequestContext
;
public
class
MyZuulDiscoveryEnabledAdapter
implements
DiscoveryEnabledAdapter
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MyZuulDiscoveryEnabledAdapter
.
class
);
@Autowired
protected
PluginAdapter
pluginAdapter
;
@Override
public
boolean
apply
(
Server
server
)
{
RequestContext
context
=
RequestContext
.
getCurrentContext
();
HttpServletRequest
request
=
context
.
getRequest
();
String
token
=
request
.
getHeader
(
"token"
);
String
serviceId
=
server
.
getMetaInfo
().
getAppName
().
toLowerCase
();
Map
<
String
,
String
>
metadata
=
pluginAdapter
.
getServerMetadata
(
server
);
LOG
.
info
(
"Zuul端负载均衡用户定制触发:serviceId={}, host={}, metadata={}, context={}"
,
serviceId
,
server
.
toString
(),
metadata
,
context
);
if
(
StringUtils
.
equals
(
token
,
"abc"
))
{
return
false
;
}
return
true
;
}
}
\ No newline at end of file
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