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
3c5d42fd
Commit
3c5d42fd
authored
Jul 28, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构类结构
parent
326f4cff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
10 deletions
+12
-10
discovery-plugin-strategy-extension-service/src/main/java/com/nepxion/discovery/plugin/strategy/extension/service/aop/ServiceStrategyInterceptor.java
+5
-4
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MyDiscoveryEnabledAdapter.java
+2
-1
discovery-springcloud-example-zuul/src/main/java/com/nepxion/discovery/plugin/example/zuul/extension/MyDiscoveryEnabledAdapter.java
+5
-5
No files found.
discovery-plugin-strategy-extension-service/src/main/java/com/nepxion/discovery/plugin/strategy/extension/service/aop/ServiceStrategyInterceptor.java
View file @
3c5d42fd
...
@@ -51,14 +51,14 @@ public class ServiceStrategyInterceptor extends AbstractInterceptor {
...
@@ -51,14 +51,14 @@ public class ServiceStrategyInterceptor extends AbstractInterceptor {
context
.
add
(
ServiceStrategyConstant
.
METHOD
,
methodName
);
context
.
add
(
ServiceStrategyConstant
.
METHOD
,
methodName
);
context
.
add
(
ServiceStrategyConstant
.
PARAMETER_MAP
,
parameterMap
);
context
.
add
(
ServiceStrategyConstant
.
PARAMETER_MAP
,
parameterMap
);
LOG
.
debug
(
"Service strategy context is set with
class={}, methodName={}, parameterMap={}"
,
proxiedClass
,
methodName
,
parameterMap
);
LOG
.
debug
(
"Service strategy context is set with
{}"
,
context
);
try
{
try
{
return
invocation
.
proceed
();
return
invocation
.
proceed
();
}
catch
(
Exception
e
)
{
throw
e
;
}
finally
{
}
finally
{
context
.
clear
();
ServiceStrategyContext
.
clearCurrentContext
();
LOG
.
debug
(
"Service strategy context is cleared"
);
}
}
}
}
}
}
\ No newline at end of file
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MyDiscoveryEnabledAdapter.java
View file @
3c5d42fd
...
@@ -11,6 +11,7 @@ package com.nepxion.discovery.plugin.example.service.extension;
...
@@ -11,6 +11,7 @@ package com.nepxion.discovery.plugin.example.service.extension;
import
java.util.Map
;
import
java.util.Map
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -41,7 +42,7 @@ public class MyDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
...
@@ -41,7 +42,7 @@ public class MyDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
if
(
attributes
.
containsKey
(
ServiceStrategyConstant
.
PARAMETER_MAP
))
{
if
(
attributes
.
containsKey
(
ServiceStrategyConstant
.
PARAMETER_MAP
))
{
Map
<
String
,
Object
>
parameterMap
=
(
Map
<
String
,
Object
>)
attributes
.
get
(
ServiceStrategyConstant
.
PARAMETER_MAP
);
Map
<
String
,
Object
>
parameterMap
=
(
Map
<
String
,
Object
>)
attributes
.
get
(
ServiceStrategyConstant
.
PARAMETER_MAP
);
String
value
=
parameterMap
.
get
(
"value"
).
toString
();
String
value
=
parameterMap
.
get
(
"value"
).
toString
();
if
(
value
.
contains
(
"abc"
))
{
if
(
StringUtils
.
isNotEmpty
(
value
)
&&
value
.
contains
(
"abc"
))
{
LOG
.
info
(
"过滤条件:当前端输入值包含'abc'的时候,不能被Ribbon负载均衡到"
);
LOG
.
info
(
"过滤条件:当前端输入值包含'abc'的时候,不能被Ribbon负载均衡到"
);
return
false
;
return
false
;
...
...
discovery-springcloud-example-zuul/src/main/java/com/nepxion/discovery/plugin/example/zuul/extension/MyDiscoveryEnabledAdapter.java
View file @
3c5d42fd
...
@@ -11,8 +11,6 @@ package com.nepxion.discovery.plugin.example.zuul.extension;
...
@@ -11,8 +11,6 @@ package com.nepxion.discovery.plugin.example.zuul.extension;
import
java.util.Map
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -32,15 +30,17 @@ public class MyDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
...
@@ -32,15 +30,17 @@ public class MyDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
@Override
@Override
public
boolean
apply
(
Server
server
)
{
public
boolean
apply
(
Server
server
)
{
RequestContext
context
=
RequestContext
.
getCurrentContext
();
RequestContext
context
=
RequestContext
.
getCurrentContext
();
HttpServletRequest
request
=
context
.
getRequest
(
);
String
token
=
context
.
getRequest
().
getHeader
(
"token"
);
String
token
=
request
.
getHeader
(
"token
"
);
// String value = context.getRequest().getParameter("value
");
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
);
LOG
.
info
(
"Zuul端负载均衡用户定制触发:serviceId={}, host={}, metadata={}, context={}"
,
serviceId
,
server
.
toString
(),
metadata
,
context
);
LOG
.
info
(
"Zuul端负载均衡用户定制触发:serviceId={}, host={}, metadata={}, context={}"
,
serviceId
,
server
.
toString
(),
metadata
,
context
);
if
(
StringUtils
.
equals
(
token
,
"abc"
))
{
if
(
StringUtils
.
isNotEmpty
(
token
)
&&
token
.
contains
(
"abc"
))
{
LOG
.
info
(
"过滤条件:当前端输入值包含'abc'的时候,不能被Ribbon负载均衡到"
);
return
false
;
return
false
;
}
}
...
...
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