|
|
@ -14,6 +14,7 @@ |
|
|
|
package org.springframework.cloud.context.scope.refresh; |
|
|
|
package org.springframework.cloud.context.scope.refresh; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.Serializable; |
|
|
|
import java.io.Serializable; |
|
|
|
|
|
|
|
import java.lang.reflect.Field; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.BeansException; |
|
|
|
import org.springframework.beans.BeansException; |
|
|
|
import org.springframework.beans.factory.config.BeanDefinition; |
|
|
|
import org.springframework.beans.factory.config.BeanDefinition; |
|
|
@ -26,8 +27,10 @@ import org.springframework.context.event.ContextRefreshedEvent; |
|
|
|
import org.springframework.context.event.EventListener; |
|
|
|
import org.springframework.context.event.EventListener; |
|
|
|
import org.springframework.core.Ordered; |
|
|
|
import org.springframework.core.Ordered; |
|
|
|
import org.springframework.core.env.ConfigurableEnvironment; |
|
|
|
import org.springframework.core.env.ConfigurableEnvironment; |
|
|
|
|
|
|
|
import org.springframework.core.env.MutablePropertySources; |
|
|
|
import org.springframework.jmx.export.annotation.ManagedOperation; |
|
|
|
import org.springframework.jmx.export.annotation.ManagedOperation; |
|
|
|
import org.springframework.jmx.export.annotation.ManagedResource; |
|
|
|
import org.springframework.jmx.export.annotation.ManagedResource; |
|
|
|
|
|
|
|
import org.springframework.util.ReflectionUtils; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
@ -150,8 +153,11 @@ public class RefreshScope extends GenericScope |
|
|
|
try { |
|
|
|
try { |
|
|
|
ConfigurationPropertiesBindingPostProcessor processor = context |
|
|
|
ConfigurationPropertiesBindingPostProcessor processor = context |
|
|
|
.getBean(ConfigurationPropertiesBindingPostProcessor.class); |
|
|
|
.getBean(ConfigurationPropertiesBindingPostProcessor.class); |
|
|
|
processor.setPropertySources(((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()); |
|
|
|
//TODO: replace reflection with agreed upon contract
|
|
|
|
processor.destroy(); |
|
|
|
Field field = ReflectionUtils.findField(ConfigurationPropertiesBindingPostProcessor.class, "propertySources"); |
|
|
|
|
|
|
|
ReflectionUtils.makeAccessible(field); |
|
|
|
|
|
|
|
MutablePropertySources propertySources = ((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources(); |
|
|
|
|
|
|
|
ReflectionUtils.setField(field, processor, propertySources); |
|
|
|
processor.afterPropertiesSet(); |
|
|
|
processor.afterPropertiesSet(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception e) { |
|
|
|
catch (Exception e) { |
|
|
|