* @return Object resulting JavaBean.
*/
protected Object createBean(final Map attributes) {
Class type = (Class) attributes.remove(BEAN_CLASS);
if (type == null) {
throw new NanoContainerMarkupException("Bean must have a beanClass attribute");
}
try {
Object bean = type.newInstance();
// now let's set the properties on the bean
for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
String name = entry.getKey().toString();
Object value = entry.getValue();
InvokerHelper.setProperty(bean, name, value);
}
return bean;
} catch (IllegalAccessException e) {
throw new NanoContainerMarkupException("Failed to create bean of type '" + type + "'. Reason: " + e, e);
} catch (InstantiationException e) {
throw new NanoContainerMarkupException("Failed to create bean of type " + type + "'. Reason: " + e, e);
}
}