public <T> NewManagedBean<T> createNewComponent(OwbBean<T> bean, Class<T> type)
{
Asserts.assertNotNull(bean, "bean");
if (!EnumSet.of(WebBeansType.MANAGED, WebBeansType.ENTERPRISE, WebBeansType.PRODUCERMETHOD, WebBeansType.PRODUCERFIELD).contains(bean.getWebBeansType()))
{
throw new WebBeansConfigurationException("@New annotation on type : " + bean.getBeanClass()
+ " must defined as a simple or an enterprise web bean");
}
AnnotatedType<T> annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(type);
BeanAttributesImpl<T> newBeanAttributes = new BeanAttributesImpl<>(bean.getTypes(), Collections.<Annotation>singleton(new NewLiteral(type)));
NewManagedBean<T> newBean = new NewManagedBean<>(bean.getWebBeansContext(), bean.getWebBeansType(), annotatedType, newBeanAttributes, type, bean.getInjectionPoints());
return newBean;
}