File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Servlet or Stateful Session bean ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Servlet or Stateful Session bean ?" Watch "Servlet or Stateful Session bean ?" New topic
Author

Servlet or Stateful Session bean ?

Srivastava Praveen
Greenhorn

Joined: Aug 14, 2007
Posts: 14
I found this question in one of the Mock test.
----------------------------------------------
You are developing an online shopping store for an art gallery. The company aims to bring fine art to the masses and expects a huge volume of traffic through the site. The site allows customers to pay for goods and arrange delivery methods using credit cards. You have read through the requirements and have a rough design in your head. Which of the following is the most appropriate rough design for this site?

AHave an Entity Bean to represent the customer. Use a Servlet to manage the users session and use BMT to manage the transactions.
BHave an Entity Bean to represent the customer. Use a Stateful Session Bean to manage the users session and use BMT to manage the transactions.
CHave an Entity Bean to represent the customer. Use a Servlet to manage the users session and use CMT to manage the transactions.
DHave an Entity Bean to represent the customer. Use a Stateful Session Bean to manage the users session and use CMT to manage the transactions.

-----------------------------------------

As per my understanding correct answer should be D. But as mock test, C is correct answer. Please suggest.
Abhinav Srivastava
Ranch Hand

Joined: Nov 19, 2002
Posts: 349

if the ejb's are to be accessed directly, stateful beans will do the job, however, in most cases you will have a web application sitting on top of the core application. its easier to do it in the web-tier as the session object is made available to servlets by the webserver.
Ricardo Ferreira
Ranch Hand

Joined: Feb 13, 2006
Posts: 156
SFSB are heavy objects. They use much more resources rather than SLSB. The questions attemps that the site are going to be accessed by a huge number of customer, so, if each access from remote user needs to open a new fat object (SFSB) you could comprimise your EJB server with so much resources.

State in this case does not need to be transactional (user sessions) so, the transacional behavior could be isolated only in the Domain Model, which is, the Entity Beans maintained by the EJB container. When using Entity Beans, only CMT are allowed to be used, so the letter 'C' could be considered the finest answer for this question.

Best Regards,


Ricardo Ferreira,<br /> <br />Sun Certified Enterprise Architect<br />IBM Certified SOA Solution Designer<br />IBM Certified RUP v7.0 Solution Designer<br />IBM Certified Specialist for RUP v2003
Abhinav Srivastava
Ranch Hand

Joined: Nov 19, 2002
Posts: 349

I'm not sure if it is conclusively proven that SFSB's are costlier than HttpSession as far as state management is concerned though it might seem that SFSB's would be costly.
Here is one study which concludes that "cost of storing data in an HTTP session object is basically the same as using a stateful session bean".
http://www.dev2dev.co.kr/pub/a/2002/10/zadrozny.jsp
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

I will also go for option D.

Using Session beans you can manage the resources more gracefully than the session object as the stateful session beans provides the activation and passivation mechanism. Also, the customer is represented as entity bean, and it look that credit card processing is done using stateless session bean. I feel it is always better to keep session data closer to business logic processing.

Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Ricardo Ferreira
Ranch Hand

Joined: Feb 13, 2006
Posts: 156
The key for your provided article is that SFSB must be removed by the client after it used for some task. Regarding this removal process, the activation and passivation operations are still be performed in the application cycle.

So, in that case, this os the cost the SFSB brings to the solution, the passivation process. Swapping objects to the disk is an expensive process. The only way that an SFSB would never passivate is using every time in order to garantee that the Container should not think that it is obsolete. Wich means that, this is a performance issue to be mitigated.

Try to make a tunning of an Application Server to engage a more detailed resume about EJB resouce management. Do not truste in this articles, they can be very intrusive to promote more Application Server sales.

Regards,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet or Stateful Session bean ?