use of org.springframework.beans.PropertyValue in project hudson-2.x by hudson.
the class DefaultRuntimeSpringConfiguration method registerBeansWithContext.
public void registerBeansWithContext(StaticApplicationContext applicationContext) {
for (BeanConfiguration bc : beanConfigs.values()) {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("[RuntimeConfiguration] Registering bean [" + bc.getName() + "]");
if (LOGGER.isLoggable(Level.FINEST)) {
PropertyValue[] pvs = bc.getBeanDefinition().getPropertyValues().getPropertyValues();
for (PropertyValue pv : pvs) {
LOGGER.finest("[RuntimeConfiguration] With property [" + pv.getName() + "] set to [" + pv.getValue() + "]");
}
}
}
if (applicationContext.containsBeanDefinition(bc.getName()))
applicationContext.removeBeanDefinition(bc.getName());
applicationContext.registerBeanDefinition(bc.getName(), bc.getBeanDefinition());
}
for (String key : beanDefinitions.keySet()) {
BeanDefinition bd = beanDefinitions.get(key);
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("[RuntimeConfiguration] Registering bean [" + key + "]");
if (LOGGER.isLoggable(Level.FINEST)) {
for (PropertyValue pv : bd.getPropertyValues().getPropertyValues()) {
LOGGER.finest("[RuntimeConfiguration] With property [" + pv.getName() + "] set to [" + pv.getValue() + "]");
}
}
}
if (applicationContext.containsBean(key)) {
applicationContext.removeBeanDefinition(key);
}
applicationContext.registerBeanDefinition(key, bd);
}
}
use of org.springframework.beans.PropertyValue in project spring-boot by spring-projects.
the class PropertySourcesPropertyValues method putIfAbsent.
private PropertyValue putIfAbsent(String propertyName, Object value, PropertySource<?> source) {
if (value != null && !this.propertyValues.containsKey(propertyName)) {
PropertySource<?> collectionOwner = this.collectionOwners.putIfAbsent(COLLECTION_PROPERTY.matcher(propertyName).replaceAll("[]"), source);
if (collectionOwner == null || collectionOwner == source) {
PropertyValue propertyValue = new OriginCapablePropertyValue(propertyName, value, propertyName, source);
this.propertyValues.put(propertyName, propertyValue);
return propertyValue;
}
}
return null;
}
use of org.springframework.beans.PropertyValue in project spring-boot by spring-projects.
the class RelaxedDataBinder method getSortedPropertyNames.
private List<String> getSortedPropertyNames(MutablePropertyValues propertyValues) {
List<String> names = new LinkedList<>();
for (PropertyValue propertyValue : propertyValues.getPropertyValueList()) {
names.add(propertyValue.getName());
}
sortPropertyNames(names);
return names;
}
use of org.springframework.beans.PropertyValue in project spring-boot by spring-projects.
the class RelaxedDataBinder method getPropertyValuesForNamePrefix.
private MutablePropertyValues getPropertyValuesForNamePrefix(MutablePropertyValues propertyValues) {
if (!StringUtils.hasText(this.namePrefix) && !this.ignoreNestedProperties) {
return propertyValues;
}
MutablePropertyValues rtn = new MutablePropertyValues();
for (PropertyValue value : propertyValues.getPropertyValues()) {
String name = value.getName();
for (String prefix : new RelaxedNames(stripLastDot(this.namePrefix))) {
for (String separator : new String[] { ".", "_" }) {
String candidate = (StringUtils.hasLength(prefix) ? prefix + separator : prefix);
if (name.startsWith(candidate)) {
name = name.substring(candidate.length());
if (!(this.ignoreNestedProperties && name.contains("."))) {
PropertyOrigin propertyOrigin = OriginCapablePropertyValue.getOrigin(value);
rtn.addPropertyValue(new OriginCapablePropertyValue(name, value.getValue(), propertyOrigin));
}
}
}
}
}
return rtn;
}
use of org.springframework.beans.PropertyValue in project spring-boot by spring-projects.
the class PropertySourcesPropertyValuesTests method testOrderPreserved.
@Test
public void testOrderPreserved() {
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
map.put("one", 1);
map.put("two", 2);
map.put("three", 3);
map.put("four", 4);
map.put("five", 5);
this.propertySources.addFirst(new MapPropertySource("ordered", map));
PropertySourcesPropertyValues propertyValues = new PropertySourcesPropertyValues(this.propertySources);
PropertyValue[] values = propertyValues.getPropertyValues();
assertThat(values).hasSize(6);
Collection<String> names = new ArrayList<>();
for (PropertyValue value : values) {
names.add(value.getName());
}
assertThat(names).containsExactly("one", "two", "three", "four", "five", "name");
}
Aggregations