Hi , In the home interface of Statless session bean we declare a create method having Return type as the Remote Interface . Then why the bean class of stateless session bean has ejbCreate() method returning void ? Thanks , Nikhil
It is the container that is responible for returning the remote component interface to the client (the instance of the stub that implements the remote component interface). The bean does not have to be involved in that. Hope it helps /Magnus
Nikhil, just to add on to what Magnus already indicated, here is how try to remember it... The container callbacks only return what the container needs in order to complete its job, and only pass what the bean needs to complete its job. That is why the ejbCreate() signatures vary across the various enterprise bean types. Stateless session beans and message-driven beans: void ejbCreate() because the container doesn't need to know anything else to identify the bean, and the bean doesn't need to know anything else in order to complete its creation. The container doesn't care about identifying the bean via a returned value, it'll just pull a bean out of the pool at random when it needs one. Stateful session beans: void ejbCreate(args) because the bean may need initialization parameters, but the container's job is done. It is going to immediately give the instance it just created to the EJBObject skeleton. Entity beans: FooPK ejbCreate(args) because the bean may (almost always does) need initialization parameters, and the container needs to know the primary key that was generated. Different clients at different times will ask to use this entity, and the only way the container can find the right instance is via the PK that was returned during creation (and probably stuffed into a hashtable somewhere). The last case is a little odd, because the signature has to accomodate both BMP and CMP. CMP ejbCreate implementation returns null because the container figures out the PK from the virtual fields and the descriptor, but BMP would return the actual PK value.
Reid - SCJP2 (April 2002)
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
a bit of art, as a gift, the permaculture playing cards