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() {
  |                     ...
  |     }
  | }

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3964368#3964368

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3964368
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to