Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF + SFSB is best practice ?

 
Marwan Adel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am asking about the separation of concerns in JSF application , Is it best practice to access service layer directly from action method or to use SFSB with CDI ?
 
Mike Degteariov
Ranch Hand
Posts: 145
8
Java Mac MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In most cases, you need this:

JSF -> CDI (@SessionScoped or @ViewScoped) -> SSB (Stateless)-> whatever your business logic requires

Session with a SFSB was originally intended for non-HTTP remote clients (Applets and Swing applications).
In a way you could say it was the RMI equivalent of the HTTP session.

Both CDI and SFSB can store the state, but CDI is bound to the HTTP session and will get destroyed automatically when either the session terminates (for @SessionScoped) or view changes (for @ViewScoped),
whereas SFSB are open ended user-managed components, and their lifetieme must be managed by a client.

So in simple CRUD JSF-based web application, SFSB should probably not be used.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic