T result = (T) beanManager.getReference(bean, type, creationalContext);
if (bean.getScope().equals(Dependent.class))
{
//TODO add serializable check again or remove this TODO once MYFACES-3805 is clarified
AbstractBeanStorage beanStorage = getContextualReference(beanManager, RequestDependentBeanStorage.class);
//noinspection unchecked
beanStorage.add(new DependentBeanEntry(result, bean, creationalContext));
}
return result;
}