• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ejbCreate() in Stateless session bean

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic