Commit 440779bc by Spencer Gibb

Revert "attempt ordering of RibbonClients.defaultConfiguration's"

This reverts commit 0d468b39.
parent 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"), 0); client.get("configuration"));
} }
} }
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("defaultConfigurationOrder")); attrs.get("defaultConfiguration"));
} }
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"), 0); registerClientConfiguration(registry, name, client.get("configuration"));
} }
} }
...@@ -76,12 +76,11 @@ public class RibbonClientConfigurationRegistrar implements ImportBeanDefinitionR ...@@ -76,12 +76,11 @@ public class RibbonClientConfigurationRegistrar implements ImportBeanDefinitionR
} }
private void registerClientConfiguration(BeanDefinitionRegistry registry, private void registerClientConfiguration(BeanDefinitionRegistry registry,
Object name, Object configuration, Object order) { Object name, Object configuration) {
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());
} }
......
...@@ -30,10 +30,4 @@ public class RibbonClientSpecification { ...@@ -30,10 +30,4 @@ public class RibbonClientSpecification {
private Class<?>[] configuration; private Class<?>[] configuration;
private int order;
public Integer order() {
return order;
}
} }
...@@ -42,5 +42,4 @@ public @interface RibbonClients { ...@@ -42,5 +42,4 @@ public @interface RibbonClients {
Class<?>[] defaultConfiguration() default {}; Class<?>[] defaultConfiguration() default {};
int defaultConfigurationOrder() default 0;
} }
...@@ -16,14 +16,11 @@ ...@@ -16,14 +16,11 @@
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;
...@@ -128,19 +125,8 @@ public class SpringClientFactory implements DisposableBean, ApplicationContextAw ...@@ -128,19 +125,8 @@ public class SpringClientFactory implements DisposableBean, ApplicationContextAw
context.register(configuration); context.register(configuration);
} }
} }
for (Entry<String, RibbonClientSpecification> entry : this.configurations
List<Entry<String, RibbonClientSpecification>> entries = new ArrayList<>(this.configurations .entrySet()) {
.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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment