BeanManagerImpl manager = BeanManagerImpl.getManager();
checkManagedBeanCondition(clazz);
ManagedBean<T> component = new ManagedBean<T>(clazz, type);
manager.putInjectionTargetWrapper(component, new InjectionTargetWrapper(new InjectionTargetProducer(component)));
WebBeansUtil.setInjectionTargetBeanEnableFlag(component);
DefinitionUtil.defineSerializable(component);
DefinitionUtil.defineStereoTypes(component, clazz.getDeclaredAnnotations());
Annotation[] clazzAnns = clazz.getDeclaredAnnotations();
DefinitionUtil.defineApiTypes(component, clazz);
DefinitionUtil.defineScopeType(component, clazzAnns, "Simple WebBean Component implementation class : " + clazz.getName()
+ " stereotypes must declare same @Scope annotations");
WebBeansUtil.checkGenericType(component);
DefinitionUtil.defineQualifiers(component, clazzAnns);
DefinitionUtil.defineName(component, clazzAnns, WebBeansUtil.getManagedBeanDefaultName(clazz.getSimpleName()));
Constructor<T> constructor = WebBeansUtil.defineConstructor(clazz);
component.setConstructor(constructor);
DefinitionUtil.addConstructorInjectionPointMetaData(component, constructor);
//Dropped from the speicification
//WebBeansUtil.checkSteroTypeRequirements(component, clazz.getDeclaredAnnotations(), "Simple WebBean Component implementation class : " + clazz.getName());
Set<ProducerMethodBean<?>> producerMethods = DefinitionUtil.defineProducerMethods(component);
for (ProducerMethodBean<?> producerMethod : producerMethods)
{
// add them one after the other to enable serialization handling et al
manager.addBean(producerMethod);
manager.putInjectionTargetWrapper(producerMethod, new InjectionTargetWrapper(new ProducerBeansProducer(producerMethod)));
}
Set<ProducerFieldBean<?>> producerFields = DefinitionUtil.defineProduerFields(component);
for (ProducerFieldBean<?> producerField : producerFields)
{
// add them one after the other to enable serialization handling et al
manager.addBean(producerField);
manager.putInjectionTargetWrapper(producerField, new InjectionTargetWrapper(new ProducerBeansProducer(producerField)));
}
DefinitionUtil.defineDisposalMethods(component);
DefinitionUtil.defineInjectedFields(component);