This is unnecessary verbose. Add a new constructor to BeansXml() that takes BeanDiscoveryMode directly.