• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Stateless Session Bean - Life Cycle

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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,
 
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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."
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic