Polishing
This commit is contained in:
@@ -45,6 +45,8 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Sam Brannen
|
||||
* @since 5.2.5
|
||||
* @see DynamicPropertiesContextCustomizerFactory
|
||||
* @see DefaultDynamicPropertyRegistry
|
||||
* @see DynamicPropertySourceBeanInitializer
|
||||
*/
|
||||
class DynamicPropertiesContextCustomizer implements ContextCustomizer {
|
||||
|
||||
@@ -59,20 +61,11 @@ class DynamicPropertiesContextCustomizer implements ContextCustomizer {
|
||||
|
||||
|
||||
DynamicPropertiesContextCustomizer(Set<Method> methods) {
|
||||
methods.forEach(this::assertValid);
|
||||
methods.forEach(DynamicPropertiesContextCustomizer::assertValid);
|
||||
this.methods = methods;
|
||||
}
|
||||
|
||||
|
||||
private void assertValid(Method method) {
|
||||
Assert.state(Modifier.isStatic(method.getModifiers()),
|
||||
() -> "@DynamicPropertySource method '" + method.getName() + "' must be static");
|
||||
Class<?>[] types = method.getParameterTypes();
|
||||
Assert.state(types.length == 1 && types[0] == DynamicPropertyRegistry.class,
|
||||
() -> "@DynamicPropertySource method '" + method.getName() +
|
||||
"' must accept a single DynamicPropertyRegistry argument");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig) {
|
||||
ConfigurableEnvironment environment = context.getEnvironment();
|
||||
@@ -115,4 +108,14 @@ class DynamicPropertiesContextCustomizer implements ContextCustomizer {
|
||||
return this.methods.hashCode();
|
||||
}
|
||||
|
||||
|
||||
private static void assertValid(Method method) {
|
||||
Assert.state(Modifier.isStatic(method.getModifiers()),
|
||||
() -> "@DynamicPropertySource method '" + method.getName() + "' must be static");
|
||||
Class<?>[] types = method.getParameterTypes();
|
||||
Assert.state(types.length == 1 && types[0] == DynamicPropertyRegistry.class,
|
||||
() -> "@DynamicPropertySource method '" + method.getName() +
|
||||
"' must accept a single DynamicPropertyRegistry argument");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ class DynamicValuesPropertySource extends MapPropertySource {
|
||||
super(PROPERTY_SOURCE_NAME, Collections.unmodifiableMap(valueSuppliers));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getProperty(String name) {
|
||||
|
||||
Reference in New Issue
Block a user