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
0d468b39
Commit
0d468b39
authored
Jun 08, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attempt ordering of RibbonClients.defaultConfiguration's
ref gh-383
parent
0f2fbf8e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
6 deletions
+28
-6
RibbonClientConfigurationRegistrar.java
...ud/netflix/ribbon/RibbonClientConfigurationRegistrar.java
+5
-4
RibbonClientSpecification.java
...ework/cloud/netflix/ribbon/RibbonClientSpecification.java
+6
-0
RibbonClients.java
...g/springframework/cloud/netflix/ribbon/RibbonClients.java
+1
-0
SpringClientFactory.java
...ngframework/cloud/netflix/ribbon/SpringClientFactory.java
+16
-2
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonClientConfigurationRegistrar.java
View file @
0d468b39
...
@@ -39,7 +39,7 @@ public class RibbonClientConfigurationRegistrar implements ImportBeanDefinitionR
...
@@ -39,7 +39,7 @@ public class RibbonClientConfigurationRegistrar implements ImportBeanDefinitionR
AnnotationAttributes
[]
clients
=
(
AnnotationAttributes
[])
attrs
.
get
(
"value"
);
AnnotationAttributes
[]
clients
=
(
AnnotationAttributes
[])
attrs
.
get
(
"value"
);
for
(
AnnotationAttributes
client
:
clients
)
{
for
(
AnnotationAttributes
client
:
clients
)
{
registerClientConfiguration
(
registry
,
getClientName
(
client
),
registerClientConfiguration
(
registry
,
getClientName
(
client
),
client
.
get
(
"configuration"
));
client
.
get
(
"configuration"
)
,
0
);
}
}
}
}
if
(
attrs
!=
null
&&
attrs
.
containsKey
(
"defaultConfiguration"
))
{
if
(
attrs
!=
null
&&
attrs
.
containsKey
(
"defaultConfiguration"
))
{
...
@@ -50,13 +50,13 @@ public class RibbonClientConfigurationRegistrar implements ImportBeanDefinitionR
...
@@ -50,13 +50,13 @@ public class RibbonClientConfigurationRegistrar implements ImportBeanDefinitionR
name
=
"default."
+
metadata
.
getClassName
();
name
=
"default."
+
metadata
.
getClassName
();
}
}
registerClientConfiguration
(
registry
,
name
,
registerClientConfiguration
(
registry
,
name
,
attrs
.
get
(
"defaultConfiguration"
));
attrs
.
get
(
"defaultConfiguration"
)
,
attrs
.
get
(
"defaultConfigurationOrder"
)
);
}
}
Map
<
String
,
Object
>
client
=
metadata
.
getAnnotationAttributes
(
Map
<
String
,
Object
>
client
=
metadata
.
getAnnotationAttributes
(
RibbonClient
.
class
.
getName
(),
true
);
RibbonClient
.
class
.
getName
(),
true
);
String
name
=
getClientName
(
client
);
String
name
=
getClientName
(
client
);
if
(
name
!=
null
)
{
if
(
name
!=
null
)
{
registerClientConfiguration
(
registry
,
name
,
client
.
get
(
"configuration"
));
registerClientConfiguration
(
registry
,
name
,
client
.
get
(
"configuration"
)
,
0
);
}
}
}
}
...
@@ -76,11 +76,12 @@ public class RibbonClientConfigurationRegistrar implements ImportBeanDefinitionR
...
@@ -76,11 +76,12 @@ public class RibbonClientConfigurationRegistrar implements ImportBeanDefinitionR
}
}
private
void
registerClientConfiguration
(
BeanDefinitionRegistry
registry
,
private
void
registerClientConfiguration
(
BeanDefinitionRegistry
registry
,
Object
name
,
Object
configuration
)
{
Object
name
,
Object
configuration
,
Object
order
)
{
BeanDefinitionBuilder
builder
=
BeanDefinitionBuilder
BeanDefinitionBuilder
builder
=
BeanDefinitionBuilder
.
genericBeanDefinition
(
RibbonClientSpecification
.
class
);
.
genericBeanDefinition
(
RibbonClientSpecification
.
class
);
builder
.
addConstructorArgValue
(
name
);
builder
.
addConstructorArgValue
(
name
);
builder
.
addConstructorArgValue
(
configuration
);
builder
.
addConstructorArgValue
(
configuration
);
builder
.
addConstructorArgValue
(
order
);
registry
.
registerBeanDefinition
(
name
+
".RibbonClientSpecification"
,
registry
.
registerBeanDefinition
(
name
+
".RibbonClientSpecification"
,
builder
.
getBeanDefinition
());
builder
.
getBeanDefinition
());
}
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonClientSpecification.java
View file @
0d468b39
...
@@ -30,4 +30,10 @@ public class RibbonClientSpecification {
...
@@ -30,4 +30,10 @@ public class RibbonClientSpecification {
private
Class
<?>[]
configuration
;
private
Class
<?>[]
configuration
;
private
int
order
;
public
Integer
order
()
{
return
order
;
}
}
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonClients.java
View file @
0d468b39
...
@@ -42,4 +42,5 @@ public @interface RibbonClients {
...
@@ -42,4 +42,5 @@ public @interface RibbonClients {
Class
<?>[]
defaultConfiguration
()
default
{};
Class
<?>[]
defaultConfiguration
()
default
{};
int
defaultConfigurationOrder
()
default
0
;
}
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/SpringClientFactory.java
View file @
0d468b39
...
@@ -16,11 +16,14 @@
...
@@ -16,11 +16,14 @@
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
;
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
...
@@ -125,8 +128,19 @@ public class SpringClientFactory implements DisposableBean, ApplicationContextAw
...
@@ -125,8 +128,19 @@ public class SpringClientFactory implements DisposableBean, ApplicationContextAw
context
.
register
(
configuration
);
context
.
register
(
configuration
);
}
}
}
}
for
(
Entry
<
String
,
RibbonClientSpecification
>
entry
:
this
.
configurations
.
entrySet
())
{
List
<
Entry
<
String
,
RibbonClientSpecification
>>
entries
=
new
ArrayList
<>(
this
.
configurations
.
entrySet
());
Collections
.
sort
(
entries
,
new
Comparator
<
Entry
<
String
,
RibbonClientSpecification
>>()
{
@Override
public
int
compare
(
Entry
<
String
,
RibbonClientSpecification
>
o1
,
Entry
<
String
,
RibbonClientSpecification
>
o2
)
{
return
o1
.
getValue
().
order
().
compareTo
(
o2
.
getValue
().
order
());
}
});
for
(
Entry
<
String
,
RibbonClientSpecification
>
entry
:
entries
)
{
if
(
entry
.
getKey
().
startsWith
(
"default."
))
{
if
(
entry
.
getKey
().
startsWith
(
"default."
))
{
for
(
Class
<?>
configuration
:
entry
.
getValue
().
getConfiguration
())
{
for
(
Class
<?>
configuration
:
entry
.
getValue
().
getConfiguration
())
{
context
.
register
(
configuration
);
context
.
register
(
configuration
);
...
...
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