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
1ede1458
Commit
1ede1458
authored
Dec 02, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get RequestInterceptors from feign context.
Rather than pulling them from the generic context. fixes gh-683
parent
f38e43a4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
17 deletions
+33
-17
FeignClientFactory.java
...ringframework/cloud/netflix/feign/FeignClientFactory.java
+9
-0
FeignClientFactoryBean.java
...framework/cloud/netflix/feign/FeignClientFactoryBean.java
+1
-1
FeignClientTests.java
...framework/cloud/netflix/feign/valid/FeignClientTests.java
+23
-16
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClientFactory.java
View file @
1ede1458
...
...
@@ -117,4 +117,13 @@ public class FeignClientFactory implements DisposableBean, ApplicationContextAwa
return
null
;
}
public
<
C
>
Map
<
String
,
C
>
getInstances
(
String
name
,
Class
<
C
>
type
)
{
AnnotationConfigApplicationContext
context
=
getContext
(
name
);
if
(
BeanFactoryUtils
.
beanNamesForTypeIncludingAncestors
(
context
,
type
).
length
>
0
)
{
return
context
.
getBeansOfType
(
type
);
}
return
null
;
}
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClientFactoryBean.java
View file @
1ede1458
...
...
@@ -100,7 +100,7 @@ class FeignClientFactoryBean implements FactoryBean<Object>, InitializingBean, A
if
(
options
!=
null
)
{
builder
.
options
(
options
);
}
Map
<
String
,
RequestInterceptor
>
requestInterceptors
=
this
.
context
.
getBeansOfType
(
RequestInterceptor
.
class
);
Map
<
String
,
RequestInterceptor
>
requestInterceptors
=
factory
.
getInstances
(
this
.
name
,
RequestInterceptor
.
class
);
if
(
requestInterceptors
!=
null
)
{
builder
.
requestInterceptors
(
requestInterceptors
.
values
());
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/valid/FeignClientTests.java
View file @
1ede1458
...
...
@@ -45,6 +45,7 @@ import org.springframework.cloud.netflix.feign.EnableFeignClients;
import
org.springframework.cloud.netflix.feign.FeignClient
;
import
org.springframework.cloud.netflix.feign.ribbon.LoadBalancerFeignClient
;
import
org.springframework.cloud.netflix.ribbon.RibbonClient
;
import
org.springframework.cloud.netflix.ribbon.RibbonClients
;
import
org.springframework.cloud.netflix.ribbon.StaticServerList
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -92,9 +93,8 @@ public class FeignClientTests {
@Autowired
private
Client
feignClient
;
// @FeignClient(value = "http://localhost:9876", loadbalance = false)
@FeignClient
(
"localapp"
)
protected
static
interface
TestClient
{
@FeignClient
(
value
=
"localapp"
,
configuration
=
TestClientConfig
.
class
)
protected
interface
TestClient
{
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/hello"
)
Hello
getHello
();
...
...
@@ -120,19 +120,7 @@ public class FeignClientTests {
ResponseEntity
head
();
}
@FeignClient
(
serviceId
=
"localapp"
)
protected
static
interface
TestClientServiceId
{
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/hello"
)
Hello
getHello
();
}
@Configuration
@EnableAutoConfiguration
@RestController
@EnableFeignClients
(
clients
=
{
TestClientServiceId
.
class
,
TestClient
.
class
},
defaultConfiguration
=
TestDefaultFeignConfig
.
class
)
@RibbonClient
(
name
=
"localapp"
,
configuration
=
LocalRibbonClientConfiguration
.
class
)
protected
static
class
Application
{
public
static
class
TestClientConfig
{
@Bean
public
RequestInterceptor
interceptor1
()
{
...
...
@@ -153,6 +141,25 @@ public class FeignClientTests {
}
};
}
}
@FeignClient
(
name
=
"localapp1"
)
protected
interface
TestClientServiceId
{
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/hello"
)
Hello
getHello
();
}
@Configuration
@EnableAutoConfiguration
@RestController
@EnableFeignClients
(
clients
=
{
TestClientServiceId
.
class
,
TestClient
.
class
},
defaultConfiguration
=
TestDefaultFeignConfig
.
class
)
@RibbonClients
({
@RibbonClient
(
name
=
"localapp"
,
configuration
=
LocalRibbonClientConfiguration
.
class
),
@RibbonClient
(
name
=
"localapp1"
,
configuration
=
LocalRibbonClientConfiguration
.
class
)
})
protected
static
class
Application
{
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/hello"
)
public
Hello
getHello
()
{
...
...
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