* @return the newly created Simple WebBean Component
* @throws WebBeansConfigurationException if any configuration exception occurs
*/
public static <T> ComponentImpl<T> define(Class<T> clazz, WebBeansType type) throws WebBeansConfigurationException
{
ManagerImpl manager = ManagerImpl.getManager();
checkSimpleWebBeanCondition(clazz);
ComponentImpl<T> component = new ComponentImpl<T>(clazz, type);
DefinitionUtil.defineSerializable(component);
DefinitionUtil.defineStereoTypes(component, clazz.getDeclaredAnnotations());
Class<? extends Annotation> deploymentType = DefinitionUtil.defineDeploymentType(component, clazz.getDeclaredAnnotations(), "There are more than one @DeploymentType annotation in Simple WebBean Component implementation class : " + component.getReturnType().getName());
// Check if the deployment type is enabled.
if (!WebBeansUtil.isDeploymentTypeEnabled(deploymentType))
{
return null;
}
Annotation[] clazzAnns = clazz.getDeclaredAnnotations();
DefinitionUtil.defineApiTypes(component, clazz);
DefinitionUtil.defineScopeType(component, clazzAnns, "Simple WebBean Component implementation class : " + clazz.getName() + " stereotypes must declare same @ScopeType annotations");
WebBeansUtil.checkPassivationScope(component, component.getScopeType().getAnnotation(ScopeType.class));
DefinitionUtil.defineBindingTypes(component, clazzAnns);
DefinitionUtil.defineName(component, clazzAnns, WebBeansUtil.getSimpleWebBeanDefaultName(clazz.getSimpleName()));
Constructor<T> constructor = WebBeansUtil.defineConstructor(clazz);
component.setConstructor(constructor);
DefinitionUtil.addConstructorInjectionPointMetaData(component, constructor);
WebBeansUtil.checkSteroTypeRequirements(component, clazz.getDeclaredAnnotations(), "Simple WebBean Component implementation class : " + clazz.getName());
Set<ProducerComponentImpl<?>> producerComponents = DefinitionUtil.defineProducerMethods(component);
manager.getBeans().addAll(producerComponents);
Set<ProducerFieldComponent<?>> producerFields = DefinitionUtil.defineProduerFields(component);
manager.getBeans().addAll(producerFields);
DefinitionUtil.defineDisposalMethods(component);
DefinitionUtil.defineInjectedFields(component);
DefinitionUtil.defineInjectedMethods(component);
DefinitionUtil.defineObserverMethods(component, clazz);