aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes SFSB Vs SLSB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "SFSB Vs SLSB" Watch "SFSB Vs SLSB" New topic
Author

SFSB Vs SLSB

Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
When a user is buying air ticket using a website,
for business logic, what is better choice

SFSB
SLSB

steps
------
1. - register user (get a used id)
2. - save credit/bank account info
3. - validate account info (deduct money)
4. - issue the ticket

Process can be implemented using SFSB as well as SLSB,
(light weight) SLSB looks good choice but business logic dependency spill over to web layer for (if money deduction is true then issue the ticket)
SFSB is the correct choice.
Am I correct?


Prasad Kumbhare
Greenhorn

Joined: Oct 18, 2007
Posts: 26
Do you have all these 1-4 operations in the same EJB and you want to traverse between that same EJB and Web layer between operation 1 to 4? Are there different EJBs for all these different steps. Basically I am trying to understnad why question is coming about Statefull and Stateless over here.
I would do this by following way.
I will have one Facade ( may be SLSB ) which in turn call different EJBs ( you can have 4 different EJBs for 4 different operations)
Thanks.


Thanks,
Prasad Kumbhare
SCJP 5.0, SCWCD 5.0, SCBCD 5.0
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
Thanks for reply.

My doubt started with following thought,

When a user is buying air ticket using a website,
for business logic, what is better choice (what should be used)

SFSB
SLSB

may sound stupid but if in exam question is like above then what should be the answer.


To get answer, I thought what are the steps for this & I added following

steps
------
1. - register user (get a used id)
2. - save credit/bank account info
3. - validate account info (deduct money)
4. - issue the ticket

I was not sure about my choice, and I thought if it is SLSB then busiess logic spills to web layer,
so SFSB is the answer (business logic does not depend on web layer)

then Session facade (SLSB) came to my mind which interacts with (further) SLSB for step 3 (deduct money) & 4 (issue ticket).
(Step 1 & 2 can be achived by SLSB (no buisness spill over to Web layer) )


Design patterns are there to help.


I am trying to understand that (it is true that using SLSB is good idea) but when it is good to use SFSB.

Sounds stupid but can't we design solutions with design pattern (e.g. session facade like in this case) to avoid using SFSB,
then in what situation we MUST used SFSB.
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
please let me know if following question is valid

When a user is buying air ticket using a website,
for business logic, what is better choice (what should be used)

SFSB
SLSB

if it is not a valid question (case/ question is not complete)
then please drop a message.

if it is valid question then - SFSB is my choice - is it correct choice.
Prasad Kumbhare
Greenhorn

Joined: Oct 18, 2007
Posts: 26
Ok. I won't say that your question is invalid. But , "When a user is buying air ticket using a website", is much complex process, though seems to be pretty one liner and so can be designed with many different solutions. SLSB or SFSB or combination of them would be one of those. Say if I have signel webservice which will do it all for me then I would just call that service from my web layer and I am done.
Anyways, I go back to your earlier post where you said "I am trying to understand that (it is true that using SLSB is good idea) but when it is good to use SFSB. ".
I think it is all depend on how you defined your transaction of work. Let me try to give you example of where we can use SFSB.

1) User submits details of air ticeket reservation on Web Page alogn with accoutn details. Call goes to EJB ( EJB - A)
2) EJB starts transaction for this request. Now design is such that within same transaction, user will be validated, bank details will be validated, ticket will be confirmed and user will be shown with ticket confirmation details. EJB did first 2 steps of transaction. When it came to verify account details, few more details are needed from use because details provided by user are not sufficient by some reason to validate. For example if User provided 5 digit Zip code and bank needs 5 + 4 combination Zip code, bank serivice will throw this request away saying need more details. I am assuming here that EJB-A calls some third party bank service to validate bank details. Coming back to our situation, now EJB-A will go back to web layer to ask user with a Popup or screen saying, please fill us, Zip Code 5 + 4 combination. Now important to note here is that, EJB-A is continuing same transaction. It is same thread. If EJB-A is not StateFul then from web layer when user submits 5+4 zip code, how we can make sure that request goes to same transaciton.
So here if EJB-A is SFSB then once use submits correct details again, request will go to same thread/transaction and EJB will complete rest two steps anc complete the ticekt processing.

But I can say, this is only one type of design. Same above I can do with SLSBs also. But I definitely need to modify my design. No arguments on that. It is afterall designers'/developers call how they want to handle this. I have seen many cases whre use of SFSB is totally not allowed. For any development they use SLSBs only. Reasons might be many. Performance. SFSB buy me more profmance overheads than SLSB. Instead of using SFSB, some use Session Databse. It gives you less worry about how if I in between tranaction of SFSB switch to a web layer which is on some other platform at all.

I hope this helps.
Thanks
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
thanks a lot for reply....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SFSB Vs SLSB
 
Similar Threads
BMT from POJO ?
servlet vs stateful session bean
partII: stateful session bean is necessary to serve as a booking cart?
Home & Remote interface
2 technical questions for the techies