List of usage examples for org.springframework.beans BeanWrapper setPropertyValues
void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid) throws BeansException;
From source file:org.walkmod.conf.entities.impl.ConfigurationImpl.java
@Override public Object getBean(String name, Map<?, ?> parameters) { Object result = null;// w w w . j av a 2 s . co m if (name == null || "".equals(name)) { return result; } if (name.equals("script")) { name = "walkmod:commons:scripting"; } else if (name.equals("template")) { name = "walkmod:commons:template"; } if (beanFactory != null && beanFactory.containsBean(name)) { result = beanFactory.getBean(name); } if (result == null) { String fullName = "org.walkmod:walkmod-" + name + "-plugin:" + name; if (!name.contains(":") && beanFactory.containsBean(fullName)) { result = beanFactory.getBean(fullName); } else { String[] parts = name.split(":"); if (parts.length == 2) { String pluginId = parts[0].trim(); String beanId = parts[1].trim(); String compositeName = "org.walkmod:walkmod-" + pluginId + "-plugin:" + beanId; if (pluginId.length() > 0 && beanId.length() > 0 && beanFactory.containsBean(compositeName)) { result = beanFactory.getBean(compositeName); } } } } if (result == null) { try { Class<?> clazz = getClassLoader().loadClass(name); result = clazz.newInstance(); } catch (Exception e) { throw new WalkModException("Sorry, it is impossible to load the bean " + name + ". Please, assure that it is a valid class name and the library which contains it is in the classpath", e); } } if (result != null) { BeanWrapper bw = new BeanWrapperImpl(result); if (this.parameters != null) { MutablePropertyValues pvs = new MutablePropertyValues(this.parameters); bw.setPropertyValues(pvs, true, true); } if (parameters != null) { MutablePropertyValues pvs = new MutablePropertyValues(parameters); bw.setPropertyValues(pvs, true, true); } } return result; }