[jboss-user] [JBoss Seam] - Re: Can i use another kind of architeture for a SEAM applica

Delphi's Ghost do-not-reply at jboss.com
Fri May 4 15:40:15 EDT 2007


If I'm understanding correctly, you want to use a more "spring like" service/dao design for developing your application? .You can implement DAOs and have them injected into your stateful beans :

I think you can implement your DAOs as stateless session beans since the only 'state' you have is injected each time the bean is called : 

(forgive the syntax errors)


  | @Stateless
  | @Name("personDAO")
  | public class PersonDAOBean implements PersonDAO {
  | 
  |   @PersistenceContex
  |   private EntityManager em;
  | 
  |   public List<Person> findPeopleByFirstName(String firstName) {
  |       return em.createQuery("Select p from person where firstName = :firstName)
  |           .setParam("firstName",firstName)
  |           .getResultList();
  |   }
  | 
  | 

In your action bean part, simply inject the DAO into it


  | @Name("personSearch")
  | @Stateful
  | @Scope(CONVERSATION)
  | public class PersonSearchBean implements PersonSearch {
  | 
  |   @In
  |   private PersonDAO personDAO;
  | 
  |   private List<Person> results;
  |   private String firstNameParam;
  | 
  | 
  |   public void doSearch() {
  |      results = personDAO.findPeopleByFirstName(firstNameParam);
  |   }
  | 
  | ...
  | 

or something like that. 





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

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4043331



More information about the jboss-user mailing list