aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Stateless Session  Bean - Life Cycle 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 "Stateless Session  Bean - Life Cycle" Watch "Stateless Session  Bean - Life Cycle" New topic
Author

Stateless Session Bean - Life Cycle

s khosa
Ranch Hand

Joined: May 15, 2003
Posts: 72
Hi,

Came across this question on SCEA yahoogroups. I thought the correct answers would be B and D. But it seems answer is D only. Any clarifications??? or Am i missing something here.

Thanks,

206When a client calls the create() on a Stateless Session Bean's Remote Interface,

AThe newInstance() method is invoked by the container
BThe ejbCreate() method is called by the container
CPassivated instance is activated and attached to the EJB Object
DThe Container takes an instance from the Method Ready Pool and attaches it to the EJB Object.

Choice D is correct.

With Stateless Session Beans, a new instance is not created each time a client request comes in. Instead, the container manages a pool of bean instances, and when a client requests the service (via a create method), an instance from the pool is assigned to service the request. Hence choice D is correct.
The newInstance() method and the ejbCreate() method are invoked by the container to set up the instances in the bean pool and are not called with each create() method called by the client. Hence choices A and B are incorrect.
Choice C is incorrect because Stateless Session Beans are not passivated or activated.
Ricardo Ferreira
Ranch Hand

Joined: Feb 13, 2006
Posts: 156
Originally posted by s khosa:
Hi,

Came across this question on SCEA yahoogroups. I thought the correct answers would be B and D. But it seems answer is D only. Any clarifications??? or Am i missing something here.

Thanks,

206When a client calls the create() on a Stateless Session Bean's Remote Interface,

AThe newInstance() method is invoked by the container
BThe ejbCreate() method is called by the container
CPassivated instance is activated and attached to the EJB Object
DThe Container takes an instance from the Method Ready Pool and attaches it to the EJB Object.

Choice D is correct.

With Stateless Session Beans, a new instance is not created each time a client request comes in. Instead, the container manages a pool of bean instances, and when a client requests the service (via a create method), an instance from the pool is assigned to service the request. Hence choice D is correct.
The newInstance() method and the ejbCreate() method are invoked by the container to set up the instances in the bean pool and are not called with each create() method called by the client. Hence choices A and B are incorrect.
Choice C is incorrect because Stateless Session Beans are not passivated or activated.


Hi,

You should take are with this questions, because they are very wear. Firstly, an client application NEVER call the create() method from the bean remote interface. It call�s from the bean HOME interface.

Second, that�s correct to say, that the bean will be handled from a pool by the ejb container. It will not create an new SLSB every time an client invoke the create() method. This is done to increase scalability using the Flyweith pattern.

If the container decides to create an SLSB (maybe it does not exist in the pool), the second method called by the container, after the create() call, it is not the ejbCreate(). It is the setSessionContext(). So every answers are missing something.

Try to study ejb�s from a good material like the 'Mastering Enterprise Java Beans', or the EJB oficial specification. There are some simulators and articles that could say something wrong about the j2ee architecture.

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
B.Sathish
Ranch Hand

Joined: Aug 18, 2005
Posts: 372
Moreover choice D is incorrect. When create() is called by the client, only an EJBObject is created and assigned to the client. The SLSB isntance in NOT attached to the EJBObject. Only when the client calls a business method, the SLSB instance is pulled out from the pool and attached to the EJBObject
Raghubir Bose
Ranch Hand

Joined: Feb 18, 2006
Posts: 88
Absolutely correct

Monsoon Haefel says ..

"Unlike the entity bean and stateful session bean, invoking the create() method does not result in a call to the bean's ejbCreate() method. In stateless session beans, calling the EJB home's create() method results in the creation of an EJB object for the client, but that is all. The ejbCreate() method of a stateless session bean is only invoked once in the life cycle of an instance--when it is transitioning from the Does Not Exist state to the Method-Ready Pool. It isn't reinvoked every time a client requests a remote reference to the bean."


I will meet the fairy queen soon !
 
jQuery in Action, 2nd edition
 
subject: Stateless Session Bean - Life Cycle