in webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java [114:163]
public T create(CreationalContext<T> creationalContext)
{
try
{
if(!(creationalContext instanceof CreationalContextImpl))
{
creationalContext = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(creationalContext, this);
}
Producer<T> producer = getProducer();
T instance = producer.produce(creationalContext);
if (producer instanceof InjectionTarget && instance != null) // @AroundConstruct can skip proceed and then it returns null
{
InjectionTarget<T> injectionTarget = (InjectionTarget<T>)producer;
injectionTarget.inject(instance, creationalContext);
injectionTarget.postConstruct(instance);
}
if (getScope().equals(Dependent.class) && instance != null)
{
((CreationalContextImpl<T>)creationalContext).addDependent(this, instance);
}
return instance;
}
catch (Exception re)
{
Throwable current = re;
Set<Throwable> visited = new HashSet<>();
while (current instanceof InvocationTargetException || current instanceof WebBeansException)
{
Throwable cause = current.getCause();
if (visited.add(cause))
{
current = cause;
}
else
{
break;
}
}
if(current != null && !(current instanceof RuntimeException))
{
throw new CreationException(current);
}
if (current == null) // just a guard but highly unlikely
{
throw new CreationException(re);
}
throw (RuntimeException) current;
}
}