8 Replies Latest reply on Aug 27, 2007 4:34 PM by pierospinelli

    @Startup with EJB having multiple roles

      Hi,

      let's consider the following case ;

      @Stateful
      @Name("firstRole")
      @Role(name="secondRole", scope=ScopeType.CONVERSATION)
      @Interceptors(SeamInterceptor.class)
      @Startup(depends={"otherBean"})
      public class MyBean{
      ...
      }


      Does the "@Startup" annotation allow a way to specify the name to be instanciated at Startup (i.e. "secondRole" instead than "firstRole")?


        • 1. Re: @Startup with EJB having multiple roles
          pmuir

          No.

          • 2. Re: @Startup with EJB having multiple roles

            Missing or useless? (I would think missing, but...)

            • 3. Re: @Startup with EJB having multiple roles
              pmuir

              Missing and, I think, useless. What is your usecase?

              • 4. Re: @Startup with EJB having multiple roles

                The use cases are all the posibble intersections between the use cases of the two features:
                - SEAM allows beans having more roles, possibly in different scopes (of course this is useful)
                - SEAM allows beans beeing instanciated in a scope at startup (this is useful too)

                Why (if not for technical reasons or simple youth of the framework) wouldn't it be allowed to use the combination of these two useful features?

                I do not say it is high-priority, but I do not think it is useless.

                p.s.
                My use case was a recursive data model (i.e. a directory like one) when a JSF table used a stateful EJB for selecting the parent and a second one (of the same type, managing the same data type) for showing the children when an item was selected in the first table.
                It worked fine in other situations, but I had a shared in-memory structure that had to be loaded in the APPLICATION scope and initialized at startup, and here I had the problem (of course solved in some other way, but it made me wonder if there were some way to do that).

                • 5. Re: @Startup with EJB having multiple roles
                  pmuir

                  Without knowing the details, I would have thought there were neater ways of doing this than making this extension to Seam. What solution did you use in the end?

                  • 6. Re: @Startup with EJB having multiple roles

                    I.e. using two distinct (but amost equals) EJBs each with a single name (no roles)

                    • 7. Re: @Startup with EJB having multiple roles

                       

                      Without knowing the details, I would have thought there were neater ways of doing this than making this extension to Seam. What solution did you use in the end?


                      Pete, if you referred to JSF recursive structures using backing EJBs, of course it presents some major problems (the first is that you cannot use recursion in EJB).

                      However, it is often possible to present a recursive structure (i.e. a Tree, a Directory, ...) focalizing on just 2 levels a time in the ui; this way the same EJB can have two roles, one for the parent level and one for the child level.

                      In order to avoid recursion in EJB it is possible to use some tricks, like moving some operations at presentation time (of course this could introduce some constaints, i.e. in the order of the control in a JSF page).

                      A sample of this could be found in a project I was ascked to upload in Jira in the thread:
                      http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4078497#4078497

                      The Jira url is http://jira.jboss.org/jira/browse/JBSEAM-1869 and the Organization page allows to manage a user directory (of couse I must have done some silly thing in it, being a new SEAM users, but maybe you could suggest me some easier way to do the same thing).

                      • 8. Re: @Startup with EJB having multiple roles

                         

                        Without knowing the details, I would have thought there were neater ways of doing this than making this extension to Seam. What solution did you use in the end?


                        Pete, if you referred to JSF recursive structures using backing EJBs, of course it presents some major problems (the first is that you cannot use recursion in EJB).

                        However, it is often possible to present a recursive structure (i.e. a Tree, a Directory, ...) focalizing on just 2 levels a time in the ui; this way the same EJB can have two roles, one for the parent level and one for the child level.

                        In order to avoid recursion in EJB it is possible to use some tricks, like moving some operations at presentation time (of course this could introduce some constaints, i.e. in the order of the control in a JSF page).

                        A sample of this could be found in a project I was ascked to upload in Jira in the thread:
                        http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4078497#4078497

                        The Jira url is http://jira.jboss.org/jira/browse/JBSEAM-1869 and the Organization page allows to manage a user directory (of couse I must have done some silly thing in it, being a new SEAM users, but maybe you could suggest me some easier way to do the same thing).