List of usage examples for org.springframework.beans PropertyValue setOptional
public void setOptional(boolean optional)
From source file:net.sourceforge.jabm.spring.PropertyOverrideWithReferencesConfigurer.java
@Override protected void applyPropertyValue(ConfigurableListableBeanFactory factory, String beanName, String property, String value) {// www.j a v a 2 s .c o m if (value != null && value.length() > 0 && !(value.charAt(0) == '&')) { super.applyPropertyValue(factory, beanName, property, value); } else { BeanDefinition bd = factory.getBeanDefinition(beanName); while (bd.getOriginatingBeanDefinition() != null) { bd = bd.getOriginatingBeanDefinition(); } Object referencedValue = new RuntimeBeanReference(value.substring(1)); PropertyValue pv = new PropertyValue(property, referencedValue); pv.setOptional(false); bd.getPropertyValues().addPropertyValue(pv); } }
From source file:org.springframework.beans.AbstractPropertyAccessorTests.java
@Test public void setUnknownOptionalProperty() { Simple target = new Simple("John", 2); AbstractPropertyAccessor accessor = createAccessor(target); try {// w w w . ja v a 2s . c o m PropertyValue value = new PropertyValue("foo", "value"); value.setOptional(true); accessor.setPropertyValue(value); } catch (NotWritablePropertyException e) { fail("Should not have failed to set an unknown optional property."); } }