The following question is from the Whizlabs SCEA simulator -
You have been contracted by a movie memorabilia company to set up an online shop. The company buys bulk goods from movie sets (stage props, costumes, gadgets etc), splits them into single items and then auctions them. The company used to hire sports halls or community centers to auction items in a traditional manner. They predict that by moving to an online solution they will reach a wider audience and make a greater profit despite the initial investment that the new system will involve. Which of the following is the most suitable initial design for this application?
A The business logic will be handled in a servlet B The business logic will be handled in a Stateful Session Bean C Use Container Managed Transactions D Use Bean Managed Transactions E The customer will be represented with an Entity Bean F There is no need for a customer bean as a customers interaction with the site is just business logic and will be handled in the Servlet/Stateful Session Bean G Use Container Managed Persistence H Use Bean Managed Persistence I The sale items will be represented with an Entity Bean J The sale items will be stored directly on a database
The explanation is as follows - Choices B, D, E, G and I are correct.
This question is really five mini questions. If the business logic is put into the Servlet, you are creating Fat clients with presentation and business logic tightly coupled. Therefore, it is more appropriate to use a Stateful Session Bean especially since the Bean can be used in the Session Facade pattern (See below). The site is an online auction site with bids being placed at different times. This implies that transactions will need to be handled at a very fine level of granularity therefore Bean Managed Transactions is the most appropriate choice.
The customer and sales items both need to be persisted so they should be implemented as Entity Beans. The Entity Beans (customer and sales items) would not be complicated objects so Container Managed Persistence would be the better choice. Session Facade : A client should never "talk" directly to an Entity EJB. Instead, a Session to Entity pattern called a Session-Facade should be used. As the name suggests, this pattern is based on the GoF Facade pattern. The Session Facade provides a simple interface to a complex subsystem. The simple interface is the Session Bean and the Complex subsystem is the Entity Bean. The client talks to the Session Bean, which in turn communicates with the Entity Bean.
I'm not clear about the explanation. Do we always choose bean managed transactions when developing auction applications ? Are we expected to make this kind of subtle design decisions ? Morover entity beans do not support BMT. Can you please comment ?
[ July 06, 2006: Message edited by: Sreedevi Vinod ] [ July 06, 2006: Message edited by: Sreedevi Vinod ]
1. customer and sale items can be represented as Entity Beans and there by CMP. 2. Besides this we have the auction business logic. How are we going to implemnet this
For Business logic since I would use sessions, so statefull session bean though not as scalable as stateless I would use it. So I choose B. Now for the Business logic, which is basically the auction process. Definitely we would need some transaction management. Since we are asked to make this [choices C or D], we have to pick what is best suited. And in this case definitely bean managed transaction, will be faster and finer control.
Then finally can implement the customer and sale as entitys and then we can use container managed persistence.
-Do know what aspect you wanted us to comment on, but I would explore every answer and see where we can apply it and or if there is a betterc choice, that way you are covering all your bases.
I agree with you. It's "subtle". I think this is not a good explanation for choice D.
"The site is an online auction site with bids being placed at different times. This implies that transactions will need to be handled at a very fine level of granularity therefore Bean Managed Transactions is the most appropriate choice. " [ July 11, 2006: Message edited by: Andr� Salvati ]
Joined: Jan 17, 2005
Thanks Andre and Kay. I think this question is vague. Suppose we take the transactions aspect. Kay said.
And in this case definitely bean managed transaction, will be faster and finer control. Then finally can implement the customer and sale as entitys and then we can use container managed persistence.
The choices simply say - Use Container Managed Transactions and Use Bean Managed Transactions. How do we specify which components should use BMT and which should use CMT ? And like Andre said, you cant decide BMT just because it is an auction application. Hope the exam questions would not be confusing like this.