Commit 5246b932 by Dave Syer

Remove reflection hack

parent aca1897f
package org.springframework.cloud.netflix.archaius;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.configuration.AbstractConfiguration;
import org.springframework.core.env.CompositePropertySource;
......@@ -16,7 +13,6 @@ import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.util.ReflectionUtils;
/**
* @author Spencer Gibb
......@@ -82,8 +78,7 @@ public class ConfigurableEnvironmentConfiguration extends AbstractConfiguration
private void extract(String root, Map<String, PropertySource<?>> map,
PropertySource<?> source) {
if (source instanceof CompositePropertySource) {
Set<PropertySource<?>> nested = getNestedPropertySources((CompositePropertySource) source);
for (PropertySource<?> nest : nested) {
for (PropertySource<?> nest : ((CompositePropertySource) source).getPropertySources()) {
extract(source.getName() + ":", map, nest);
}
}
......@@ -92,16 +87,4 @@ public class ConfigurableEnvironmentConfiguration extends AbstractConfiguration
}
}
@SuppressWarnings("unchecked")
private Set<PropertySource<?>> getNestedPropertySources(CompositePropertySource source) {
try {
Field field = ReflectionUtils.findField(CompositePropertySource.class,
"propertySources");
field.setAccessible(true);
return (Set<PropertySource<?>>) field.get(source);
}
catch (Exception ex) {
return Collections.emptySet();
}
}
}
package org.springframework.cloud.netflix.zuul;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
......@@ -16,10 +15,8 @@ import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.context.environment.EnvironmentChangeEvent;
import org.springframework.cloud.netflix.zuul.ZuulProperties.ZuulRoute;
import org.springframework.context.ApplicationListener;
import org.springframework.core.env.CompositePropertySource;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
/**
......@@ -36,8 +33,6 @@ public class ProxyRouteLocator implements ApplicationListener<EnvironmentChangeE
private PathMatcher pathMatcher = new AntPathMatcher();
private Field propertySourcesField;
private AtomicReference<Map<String, ZuulRoute>> routes = new AtomicReference<>();
private Map<String, String> staticRoutes = new LinkedHashMap<String, String>();
......@@ -45,13 +40,6 @@ public class ProxyRouteLocator implements ApplicationListener<EnvironmentChangeE
public ProxyRouteLocator(DiscoveryClient discovery, ZuulProperties properties) {
this.discovery = discovery;
this.properties = properties;
initField();
}
private void initField() {
propertySourcesField = ReflectionUtils.findField(CompositePropertySource.class,
"propertySources");
propertySourcesField.setAccessible(true);
}
@Override
......
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