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
5fc76aaa
Commit
5fc76aaa
authored
Apr 19, 2016
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix javadocs in @FeignClient
The descriptions of name/serviceId/value and url were out of date (name is mandatory now and can be mixed with url).
parent
24579f67
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
23 deletions
+34
-23
FeignClient.java
.../org/springframework/cloud/netflix/feign/FeignClient.java
+5
-6
FeignClientsRegistrar.java
...gframework/cloud/netflix/feign/FeignClientsRegistrar.java
+9
-3
LoadBalancerFeignClientOverrideTests.java
...ix/feign/ribbon/LoadBalancerFeignClientOverrideTests.java
+20
-14
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClient.java
View file @
5fc76aaa
...
...
@@ -38,21 +38,20 @@ import org.springframework.core.annotation.AliasFor;
public
@interface
FeignClient
{
/**
* The
serviceId with optional protocol prefix. Synonym for {@link #serviceId
()
*
serviceId}. Either serviceId or url must be specified but not both. Can be
* specified as property key, eg: ${propertyKey}.
* The
name of the service with optional protocol prefix. Synonym for {@link #name
()
*
name}. A name must be specified for all clients, whether or not a url is provided.
*
Can be
specified as property key, eg: ${propertyKey}.
*/
@AliasFor
(
"name"
)
String
value
()
default
""
;
/**
* The serviceId with optional protocol prefix. Synonym for {@link #value() value}.
* Either serviceId or url must be specified but not both. Can be
* specified as property key, eg: ${propertyKey}.
* The service id with optional protocol prefix. Synonym for {@link #value() value}.
*
* @deprecated use {@link #name() name} instead
*/
@Deprecated
@AliasFor
(
"value"
)
String
serviceId
()
default
""
;
@AliasFor
(
"value"
)
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClientsRegistrar.java
View file @
5fc76aaa
...
...
@@ -181,15 +181,21 @@ public class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar,
String
alias
=
name
+
"FeignClient"
;
AbstractBeanDefinition
beanDefinition
=
definition
.
getBeanDefinition
();
beanDefinition
.
setPrimary
(
true
);
BeanDefinitionHolder
holder
=
new
BeanDefinitionHolder
(
beanDefinition
,
className
,
new
String
[]{
alias
});
BeanDefinitionHolder
holder
=
new
BeanDefinitionHolder
(
beanDefinition
,
className
,
new
String
[]
{
alias
});
BeanDefinitionReaderUtils
.
registerBeanDefinition
(
holder
,
registry
);
}
private
void
validate
(
Map
<
String
,
Object
>
attributes
)
{
if
(
StringUtils
.
hasText
((
String
)
attributes
.
get
(
"value"
)))
{
Assert
.
isTrue
(!
StringUtils
.
hasText
((
String
)
attributes
.
get
(
"name"
)),
"Either name or value can be specified, but not both"
);
Assert
.
isTrue
(!
StringUtils
.
hasText
((
String
)
attributes
.
get
(
"serviceId"
)),
"Either serviceId or value can be specified, but not both"
);
"Either name (serviceId) or value can be specified, but not both"
);
}
if
(
StringUtils
.
hasText
((
String
)
attributes
.
get
(
"name"
)))
{
Assert
.
isTrue
(!
StringUtils
.
hasText
((
String
)
attributes
.
get
(
"serviceId"
)),
"Either name or serviceId can be specified, but not both"
);
}
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/ribbon/LoadBalancerFeignClientOverrideTests.java
View file @
5fc76aaa
...
...
@@ -34,10 +34,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
com.netflix.client.config.CommonClientConfigKey
;
import
com.netflix.client.config.IClientConfig
;
import
feign.Request
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
feign.Request
;
/**
* @author Spencer Gibb
*/
...
...
@@ -45,7 +45,7 @@ import static org.junit.Assert.assertEquals;
@SpringApplicationConfiguration
(
classes
=
LoadBalancerFeignClientOverrideTests
.
TestConfiguration
.
class
)
@WebIntegrationTest
(
randomPort
=
true
,
value
=
{
"spring.application.name=loadBalancerFeignClientTests"
,
"feign.httpclient.enabled=false"
,
"feign.okhttp.enabled=false"
})
"feign.httpclient.enabled=false"
,
"feign.okhttp.enabled=false"
})
@DirtiesContext
public
class
LoadBalancerFeignClientOverrideTests
{
...
...
@@ -55,27 +55,34 @@ public class LoadBalancerFeignClientOverrideTests {
@Test
public
void
overrideRequestOptions
()
{
// specific ribbon 'bar' configuration via spring bean
Request
.
Options
barOptions
=
this
.
context
.
getInstance
(
"bar"
,
Request
.
Options
.
class
);
Request
.
Options
barOptions
=
this
.
context
.
getInstance
(
"bar"
,
Request
.
Options
.
class
);
assertEquals
(
1
,
barOptions
.
connectTimeoutMillis
());
assertEquals
(
2
,
barOptions
.
readTimeoutMillis
());
assertOptions
(
barOptions
,
"bar"
,
1
,
2
);
// specific ribbon 'foo' configuration
Request
.
Options
fooOptions
=
this
.
context
.
getInstance
(
"foo"
,
Request
.
Options
.
class
);
// specific ribbon 'foo' configuration via application.yml
Request
.
Options
fooOptions
=
this
.
context
.
getInstance
(
"foo"
,
Request
.
Options
.
class
);
assertEquals
(
LoadBalancerFeignClient
.
DEFAULT_OPTIONS
,
fooOptions
);
assertOptions
(
fooOptions
,
"foo"
,
7
,
17
);
// generic ribbon default configuration
Request
.
Options
bazOptions
=
this
.
context
.
getInstance
(
"baz"
,
Request
.
Options
.
class
);
assertEquals
(
LoadBalancerFeignClient
.
DEFAULT_OPTIONS
,
fooOptions
);
Request
.
Options
bazOptions
=
this
.
context
.
getInstance
(
"baz"
,
Request
.
Options
.
class
);
assertEquals
(
LoadBalancerFeignClient
.
DEFAULT_OPTIONS
,
bazOptions
);
assertOptions
(
bazOptions
,
"baz"
,
3001
,
60001
);
}
void
assertOptions
(
Request
.
Options
options
,
String
name
,
int
expectedConnect
,
int
expectedRead
)
{
LoadBalancerFeignClient
client
=
this
.
context
.
getInstance
(
name
,
LoadBalancerFeignClient
.
class
);
void
assertOptions
(
Request
.
Options
options
,
String
name
,
int
expectedConnect
,
int
expectedRead
)
{
LoadBalancerFeignClient
client
=
this
.
context
.
getInstance
(
name
,
LoadBalancerFeignClient
.
class
);
IClientConfig
config
=
client
.
getClientConfig
(
options
,
name
);
assertEquals
(
"connect was wrong for "
+
name
,
expectedConnect
,
config
.
get
(
CommonClientConfigKey
.
ConnectTimeout
,
-
1
).
intValue
());
assertEquals
(
"read was wrong for "
+
name
,
expectedRead
,
config
.
get
(
CommonClientConfigKey
.
ReadTimeout
,
-
1
).
intValue
());
assertEquals
(
"connect was wrong for "
+
name
,
expectedConnect
,
config
.
get
(
CommonClientConfigKey
.
ConnectTimeout
,
-
1
).
intValue
());
assertEquals
(
"read was wrong for "
+
name
,
expectedRead
,
config
.
get
(
CommonClientConfigKey
.
ReadTimeout
,
-
1
).
intValue
());
}
@Configuration
...
...
@@ -107,10 +114,9 @@ public class LoadBalancerFeignClientOverrideTests {
}
}
@FeignClient
(
value
=
"baz"
)
@FeignClient
(
"baz"
)
interface
BazClient
{
@RequestMapping
(
"/"
)
String
get
();
}
}
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