protected Object getContextualInstance()
{
Object webbeansInstance = null;
//Context of the bean
Context webbeansContext = getBeanManager().getContext(this.bean.getScope());
//Already saved in context?
webbeansInstance = webbeansContext.get(this.bean);
if (webbeansInstance != null)
{
// voila, we are finished if we found an existing contextual instance
return webbeansInstance;
}
// finally, we create a new contextual instance
webbeansInstance = webbeansContext.get((Contextual<Object>)this.bean, getContextualCreationalContext());
if (webbeansInstance == null)
{
throw new UnproxyableResolutionException("Cannot find a contextual instance of bean " + bean.toString());
}