8 Replies Latest reply on May 6, 2010 1:11 PM by pmuir

    default scope of SFSBs

    asookazian

      http://docs.jboss.org/weld/reference/latest/en-US/html/scopescontexts.html


      In Seam 2.x, SFSBs are conversation-scoped by default.


      What about in Weld/Seam3?


      For example, this bean has the scope type @Dependent:
      
      public class Calculator { ... }



      @Stateful
      @ConversationScoped
      public class Calculator { ... }



      So the developer must actually add @ConversationScoped to the SFSB now?  Wouldn't we actually want the default to be conversation-scoped for a JSF backing bean rather than dependent-scoped?

        • 1. Re: default scope of SFSBs
          nickarls

          You can probably write an extension for that if you need it.

          • 2. Re: default scope of SFSBs
            asookazian

            But thinking along the lines of convention over configuration, why is an extension required?  Why can't it be part of CDI/Weld by default?  Are SFSBs going to be used as dependent-scoped mostly?

            • 3. Re: default scope of SFSBs
              nickarls

              CDI says so (all beans, not just SFSB). Perhaps because it would place the proxying requirements (no-args ctor) on all beans.

              • 4. Re: default scope of SFSBs
                asookazian

                So does this mean SFSBs in Seam 3 will not be conversation-scoped by default??

                • 5. Re: default scope of SFSBs
                  nickarls

                  I don't know what Pete has planned, I'm just quoting Scripture. Actually SFSB:s are all serializable so that would making them @ConversationScoped by default a bit more straightforward if we go down that path.

                  • 6. Re: default scope of SFSBs
                    pmuir

                    Arbi Sookazian wrote on Apr 27, 2010 22:27:


                    So does this mean SFSBs in Seam 3 will not be conversation-scoped by default??


                    No, they will be dependent scoped. This is the most useful and common scope for most beans IMO. Don't forget you have stereotypes too.

                    • 7. Re: default scope of SFSBs
                      ruarcoconnell

                      Pete Muir wrote on Apr 28, 2010 11:51:

                      No, [stateful EJBs] will be dependent scoped. This is the most useful and common scope for most beans IMO. Don't forget you have stereotypes too.


                      Wait... what?! Why would dependent scope be most useful for stateful EJBs? I mean, why make them stateful if you're going to destroy them on the very next evaluation? If @Dependent was the the most common scope we wouldn't be needing contextual dependency injection at all.

                      • 8. Re: default scope of SFSBs
                        pmuir

                        Ruarc O'Connell wrote on May 05, 2010 21:13:



                        Pete Muir wrote on Apr 28, 2010 11:51:

                        No, [stateful EJBs] will be dependent scoped. This is the most useful and common scope for most beans IMO. Don't forget you have stereotypes too.


                        Wait... what?! Why would dependent scope be most useful for stateful EJBs? I mean, why make them stateful if you're going to destroy them on the very next evaluation? If @Dependent was the the most common scope we wouldn't be needing contextual dependency injection at all.


                        You're misunderstanding dependent scoped - it means that the dependent scoped bean (BeanA) effectively has the same scope scope as the bean (BeanB) you are injecting it into. For example, say BeanB is request scoped - then BeanA will be destroyed at the end of the request.


                        My assertion that it is the most useful scope is based on the observation that the number of beans that serve as endpoints (e.g. view controllers, remote endpoints etc.) are less than the number of beans that are used for internal services.