1 Reply Latest reply on Aug 16, 2006 9:54 AM by gus888

    Question on Seam example

    gus888

      Hi Peter(petemuir) and other friends,

      I have a question in the seam example. I found there are two different ways for one session bean (event, conversation and session) calling another session bean. One way is inject a session bean in a stateless bean and call another session bean. The other is inject a session directly into another session bean and call the session bean. I am wondering whether the two way are equivelent or not, and at which situation one way is better than the other way. Thank you so much in advance. The two way example codes are as follows:

      One way:

      @Name("projectFinder")
      @Stateful
      @Scope(ScopeType.SESSION)
      public class ProjectFinderBean implements ProjectFinder {
      
       @DataModel(scope=ScopeType.PAGE)
       private List<Project> projectList;
      
       @DataModelSelection
       private Project selectedProject;
      
       public Project getSelection() {
       return selectedProject;
       }
       ...
      
      }
      
      @Stateless
      @Name("projectSelector")
      public class ProjectSelectorBean implements ProjectSelector {
      
       @In(create=true)
       private transient ProjectFinder projectFinder;
      
       public String select() {
       projectEditor.setInstance( projectFinder.getSelection() );
       executeQuery();
       return "findIssue";
       }
      }
      
      @Name("issueFinder")
      @Stateful
      @Scope(ScopeType.SESSION)
      public class IssueFinderBean implements IssueFinder {
      
       public void setProject(Project project) {
       this.project = project;
       }
      
       public void executeQuery() {
       ...
       }
      }
      

      The other way:
      @Name("projectFinder")
      @Stateful
      @Scope(ScopeType.SESSION)
      public class ProjectFinderBean implements ProjectFinder {
      
       @DataModel(scope=ScopeType.PAGE)
       private List<Project> projectList;
      
       @DataModelSelection
       private Project selectedProject;
      
       public Project getSelection() {
       return selectedProject;
       }
       ...
      
      }
      
      @Name("issueFinder")
      @Stateful
      @Scope(ScopeType.SESSION)
      public class IssueFinderBean implements IssueFinder {
      
       @In(create=true)
       private transient ProjectFinder projectFinder;
      
      
       public String select() {
       project = projectFinder.getSelection();
       executeQuery();
       return "findIssue";
       }
      
       public void executeQuery() {
       ...
       }
      }


        • 1. Re: Question on Seam example
          gus888

          Hi,

          My idea is:
          * If two SESSION scope SFSBs need to interact each other (e.g.pass some values), it is better to use a STATELESS session bean as a bridge to transfer value and action between the two SESSION scope SFSBs (SFSB ->SLSB -> SFSB). This way is better than directly injecting a SESSION scope SFSB into another SESSION scope SFSB.
          * If two EVENT or CONVERSATION scope SFSBs need to interact each other, it doesn't matter, the two injection ways (SFSB ->SLSB -> SFSB; SFSB -> SFSB) work similarly.
          Is it correct? It will be appreciated if some experts confirm this. Thank you.