Assert.notNull(beanFactory, "beanFactory cannot be null");
Assert.notNull(contributions, "contributions cannot be null");
Object registryBean = beanFactory.getBean(registryBeanName);
final Registry registry = ObjectUtils.cast(registryBean, Registry.class);
final Set<String> keys = contributions.keySet();
for (String key : keys) {
final String registrationKey = contributions.get(key);
final Object bean = beanFactory.getBean(key);
if (bean != null) {
try {
registry.addItem(registrationKey, bean);
} catch (ClassCastException e) {
throw new ConfigurationException("Bean '" + key + "' is not type compatible with " +
"registry bean '" + registryBeanName + "'");
}
}