javaeetutorial
  1. javaeetutorial
  2. JAVAEETUTORIAL-68

Need more information on scopes and concurrent access

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.0.4
    • Fix Version/s: 6.0.7-4
    • Component/s: doc
    • Labels:
      None

      Description

      A user writes,

      In Chapter 14 Configuring JavaServer Faces Applications; in the section Using Managed Bean Scopes, it states:

      If your managed bean takes part in a single HTTP request, you should define the bean with a request scope. If you placed the bean in session or application scope instead, the bean would need to take precautions to ensure thread safety because component instances depend on running inside of a single thread.

      I think that even a request scoped bean could need to be coded to handle concurrent access, say if it had a static variable. So I don't know that bean scope has any real bearing on the need to handle multi-threaded access. Certainly, the "larger" the scope, the more possibility there is for concurrent access, but I don't believe concurrent access is limited to beans of a particular scope or scopes. It seems to me that managed beans are not any different than any other code in this respect: you just have to be aware of your code and the type of threading it is subject to. If it has data that could be subject to multi-threaded access, you need to code for that (regardless of the beans scope).

      But I'm no expert on concurrency...

        Activity

        Hide
        Kim Haase added a comment -

        This was a change made at EE 6 that made the text incorrect. The need to use request scope applies only if the bean is referenced by one or more component binding expressions, because UIComponent instances depend on running in a single thread. If you bind to properties rather than component instances, you can use other scopes with no problems even if the bean only takes part in a single HTTP request.

        Show
        Kim Haase added a comment - This was a change made at EE 6 that made the text incorrect. The need to use request scope applies only if the bean is referenced by one or more component binding expressions, because UIComponent instances depend on running in a single thread. If you bind to properties rather than component instances, you can use other scopes with no problems even if the bean only takes part in a single HTTP request.
        Hide
        Kim Haase added a comment -

        Checked in fix for JSF configuration chapter.

        Show
        Kim Haase added a comment - Checked in fix for JSF configuration chapter.

          People

          • Assignee:
            Kim Haase
            Reporter:
            Kim Haase
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: