<managed-bean-scope> could also be an EL expression, to allow easy implementation of new scopes

Details

Description

See jsf 2.0 spec section 5.3

It seems we need to parse the string returned from managedBean.getManagedBeanScope(), but fortunately this problem is already solved in facelets (see TagAttributeImpl and org.apache.myfaces.view.facelets.el.ELText)

Jakob Korherr
added a comment - 11/Oct/09 18:16 Should cyclic references be detected, or not?
Scenario: Managed bean m1 has a custom scope #
{m2.scope}
and managed bean m2 has a custom scope #
{m1.scope}
.
In this scenario you will get a StackOverflowException when trying to create one of the two managed beans.
RI really ends in a StackOverflowException, should MyFaces end in such a Exception too or detect the cyclic reference and throw a ELException?

Mike Kienenberger
added a comment - 12/Oct/09 20:17 If it's easy to do, I'd say do it. It's only a performance issue on the initial startup, right?
We have a precedent set on making MyFaces proactive on detecting error conditions in the configuration.

Jakob Korherr
added a comment - 12/Oct/09 20:53 It is not really difficult, but the (little) performance issue happens every time a managed-bean instance is created. So not only at MyFaces startup. That's the problem!

Can we change the behavior so that we only check it on startup or reconfiguration?
Might require an additional set of code, but that seems like the correct approach rather than checking it every usage.

Mike Kienenberger
added a comment - 12/Oct/09 20:58 Can we change the behavior so that we only check it on startup or reconfiguration?
Might require an additional set of code, but that seems like the correct approach rather than checking it every usage.

Jakob Korherr
added a comment - 12/Oct/09 21:05 I have already thought of that, but the problem with this solution is, that you can configure a custom scope of for example #
{myBean.scope}
, which, of course, can be different every time you evaluate it.

The patch provides support for ValueExpressions in managed-bean-scope, it detects cyclic references in custom scopes (if ProjectStage != Production), it improves the detection of properties, which point to an object with a potentially shorter lifetime, by using a comparator and it also does this detection for managed-beans in custom scopes (if ProjectStage != Production).

Jakob Korherr
added a comment - 15/Oct/09 13:45 Here is my patch for this issue, including some test cases.
The patch provides support for ValueExpressions in managed-bean-scope, it detects cyclic references in custom scopes (if ProjectStage != Production), it improves the detection of properties, which point to an object with a potentially shorter lifetime, by using a comparator and it also does this detection for managed-beans in custom scopes (if ProjectStage != Production).