MyFaces Core
  1. MyFaces Core
  2. MYFACES-2375

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

    Details

    • Type: Task Task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0-alpha
    • Component/s: JSR-314
    • Labels:
      None

      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)

        Activity

        Hide
        Jakob Korherr added a comment -

        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?

        Show
        Jakob Korherr added a comment - 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?
        Hide
        Mike Kienenberger added a comment -

        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.

        Show
        Mike Kienenberger added a comment - 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.
        Hide
        Jakob Korherr added a comment -

        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!

        Show
        Jakob Korherr added a comment - 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!
        Hide
        Mike Kienenberger added a comment -

        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.

        Show
        Mike Kienenberger added a comment - 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.
        Hide
        Jakob Korherr added a comment -

        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.

        Show
        Jakob Korherr added a comment - 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.
        Hide
        Mike Kienenberger added a comment -

        Well, it's a good question.
        At this point, it's probably worthwhile to take it it the dev list rather than discussing it in a jira.

        Show
        Mike Kienenberger added a comment - Well, it's a good question. At this point, it's probably worthwhile to take it it the dev list rather than discussing it in a jira.
        Hide
        Jakob Korherr added a comment -

        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).

        Show
        Jakob Korherr added a comment - 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).
        Hide
        Leonardo Uribe added a comment -

        Thanks to Jakob Korherr for provide this patch

        Show
        Leonardo Uribe added a comment - Thanks to Jakob Korherr for provide this patch

          People

          • Assignee:
            Leonardo Uribe
            Reporter:
            Leonardo Uribe
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development