protect PropertyWrapper writeTo call

This commit is contained in:
Branislav Stojkovic
2019-03-02 15:55:24 +01:00
parent c0c226c580
commit 777f4aa3fd
2 changed files with 14 additions and 7 deletions
@@ -236,7 +236,7 @@ public class InstantiationManager {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<IDIYComponent<?>> instantiateComponent(ComponentType componentType, Template template, Point point, public List<IDIYComponent<?>> instantiateComponent(ComponentType componentType, Template template, Point point,
Project currentProject) throws Exception { Project currentProject) throws InstantiationException, IllegalAccessException {
LOG.info("Instatiating component of type: " + componentType.getInstanceClass().getName()); LOG.info("Instatiating component of type: " + componentType.getInstanceClass().getName());
// Instantiate the component. // Instantiate the component.
@@ -321,8 +321,7 @@ public class InstantiationManager {
* @throws NoSuchMethodException * @throws NoSuchMethodException
* @throws SecurityException * @throws SecurityException
*/ */
public void fillWithDefaultProperties(Object object, Template template) throws IllegalArgumentException, public void fillWithDefaultProperties(Object object, Template template) {
IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException {
// Extract properties. // Extract properties.
List<PropertyWrapper> properties = ComponentProcessor.getInstance().extractProperties(object.getClass()); List<PropertyWrapper> properties = ComponentProcessor.getInstance().extractProperties(object.getClass());
Map<String, PropertyWrapper> propertyCache = new HashMap<String, PropertyWrapper>(); Map<String, PropertyWrapper> propertyCache = new HashMap<String, PropertyWrapper>();
@@ -333,8 +332,12 @@ public class InstantiationManager {
ConfigurationManager.getInstance().readObject( ConfigurationManager.getInstance().readObject(
Presenter.DEFAULTS_KEY_PREFIX + object.getClass().getName() + ":" + property.getName(), null); Presenter.DEFAULTS_KEY_PREFIX + object.getClass().getName() + ":" + property.getName(), null);
if (defaultValue != null) { if (defaultValue != null) {
property.setValue(defaultValue); property.setValue(defaultValue);
property.writeTo(object); try {
property.writeTo(object);
} catch (Exception e) {
LOG.error("Could not write property " + property.getName(), e);
}
} }
} }
if (template != null) { if (template != null) {
@@ -344,8 +347,12 @@ public class InstantiationManager {
LOG.warn("Cannot find property " + pair.getKey()); LOG.warn("Cannot find property " + pair.getKey());
} else { } else {
LOG.debug("Filling value from template for " + pair.getKey()); LOG.debug("Filling value from template for " + pair.getKey());
property.setValue(pair.getValue()); property.setValue(pair.getValue());
property.writeTo(object); try {
property.writeTo(object);
} catch (Exception e) {
LOG.error("Could not write property " + property.getName(), e);
}
} }
} }
} }
Binary file not shown.