BeanMetadata metadata = new BeanMetadata(beanInstance);
modelMetadata.add(metadata);
// Set the namespace to the default namespace for that bean. Can be
// changed later, if needed...
DefaultNamespace defaultNs = beanInstance.getClass().getAnnotation(DefaultNamespace.class);
if(defaultNs == null) {
BeanRegistrationException.throwBeanNotAnnotatedWithDefaultNamespace(beanInstance);
}
metadata.setNamespace(defaultNs.uri());
metadata.setNamespacePrefix(defaultNs.prefix());
return metadata;
}