• 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

Operations allowed in the methods of a stateless session bean

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Page 228 of HFEJB

Bean things that you can do from stateless bean methods:
In the ejbCreate() and ejbRemove() methods,
a) get a reference to your home
b) get a reference to your EJB object

I can understand (a). But I am not able to understand how (b) can be done.

When ejbCreate() is called by the container, there is no EJBObject in the picture. My understanding is that the ejbCreate() and the client call are not tied to each other for a stateless session bean - the container decides when to create beans.
How can we get a reference to EJB object using my session context in this case? Can someone please explain? I am not sure if my understanding is right.
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In principle you are correct. However the SessionContext states:


An instance of a session enterprise Bean can call this method at anytime between the ejbCreate() and ejbRemove() methods, including from within the ejbCreate() and ejbRemove() methods.

An instance can use this method, for example, when it wants to pass a reference to itself in a method argument or result.



This made me assume that for a stateless session bean it would simply create an EJBObject instance which the bean instance could then return during its lifetime (in lieu of "this") - which would be perfectly acceptable as no EJBObject instance is linked to any specific instance of the same stateless session bean type anyway.

However, I have no further proof to offer.
 
Ramakrishnan Viswanathan
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Peer.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also do not lose sight of the fact that the EJBObject/Component Interface is a conceptual object/instance. The Server/Container providers can do what they want, as long as they adhere to the contracts outlined in the specification.

I somehow doubt that most containers actually create discrete instances of the various component interfaces unless its done with something like the Flyweight design pattern in front of something that resembles a front-end transaction processor.

So in fact there may already be something out there that can act as the EJBObject for a stateless session bean during the ejbCreate - nothing has to be actually created.
 
Ramakrishnan Viswanathan
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got you.
 
What's wrong? Where are you going? Stop! Read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic