I traced the example PhaseListener (and MyFaces ExtVal startup) thru a debugger and found whats going on.
Weld has an ELCreationalContext which works with a stack, ValueExpressions always push/pop the stack, whereas ELResolver expects the stack to have already been pushed in the case of Dependent scoped objects.
Excerpts from org.jboss.weld.el.AbstractWeldELResolver:
privateObject lookup(BeanManagerImpl beanManager, ELContext context, String name) {
final Bean<?> bean = beanManager.resolve(beanManager.getBeans(name));
if (bean == null) {
returnnull;
}
Class<? extends Annotation> scope = bean.getScope();
if (!scope.equals(Dependent.class)) {
ClientProxyProvider cpp = beanManager.getClientProxyProvider();
if (cpp != null) {
Object value = cpp.getClientProxy(bean);
if (value != null) {
return value;
}
}
return beanManager.getReference(bean, beanManager.createCreationalContext(bean), false);
} else {
// Need to use a "special" creationalContext that can make sure that we do share dependent instances referenced by the EL Expression
final ELCreationalContext<?> creationalContext = getELCreationalContext(context);
String beanName = bean.getName();
Object value = creationalContext.getDependentInstanceForExpression(beanName);
if (value == null) {
value = getManager(context).getReference(bean, creationalContext, false);
creationalContext.registerDependentInstanceForExpression(beanName, value);
}
return value;
}
}
private ELCreationalContext<?> getELCreationalContext(ELContext context) {
ELCreationalContextStack stack = ELCreationalContextStack.getCreationalContextStore(context);
if (!stack.isEmpty()) {
return stack.peek().get();
} else {
thrownew IllegalStateException("No CreationalContext registered for EL evaluation, it is likely that the the expression factory has not been wrapped by the CDI BeanManager, which must be done to use the ELResolver from CDI");
}
}
Excerpts from org.jboss.weld.el.WeldValueExpression:
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
I traced the example PhaseListener (and MyFaces ExtVal startup) thru a debugger and found whats going on.
Weld has an ELCreationalContext which works with a stack, ValueExpressions always push/pop the stack, whereas ELResolver expects the stack to have already been pushed in the case of Dependent scoped objects.
Excerpts from org.jboss.weld.el.AbstractWeldELResolver:
Excerpts from org.jboss.weld.el.WeldValueExpression: