• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

Why can stateless ejbCreate() access EJBObject

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I know this is an old question but can anyone answer it ?

Stateless session bean ejbCreate()is completely decoupled from a clients create() call so how on earth can it get a reference to EJBObject !

Thanks,
Satish
 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it can access its interfaces through its SessionContext, by calling the methods getEJBObject or getEJBLocalObject.
 
satish bance
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What i mean is ...

A stateless session bean is created by the container when it wants to ...

constructor()
setSessionContext()
ejbCreate()

but at no time in this lifecycle is there any EJBObject so how can you refer to it in ejbCreate() ?
 
Ådne Brunborg
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, so what you ask is not "how can a SSB get a reference to it EJBObject during ejbCreate?" but "how can a SSB know which instance of the EJBObject it belongs to, during ejbCreate?".

Easier to discuss if discussion is not limited to ejbCreate, since I cannot think of a good reason I'd want to, but rather to anywhere in the bean - you might want to call another business method in another transaction context, so you cannot call it directly in the bean.

Since all stateless session beans are identical (isIdentical is always true for beans of the same class) it doesn't matter which instance of the bean you are directed to. (Unless you intend to modify a global variable, in which case your code needs to be redesigned )

So I guess the answer would be - it doesn't matter which instance of the EJBObject you use, so you can use any, on the containers discretion.

Did this answer your question?
[ October 19, 2006: Message edited by: �dne Brunborg ]
 
satish bance
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take this mythical scenario ...

Say for example the container creates a stateless session bean and put it in the pool and invoked ejbCreate(). If no client ever came along and called EJBHome.create() then no EJBObject would ever be created. In which case how could a stateless session bean ever refer to an EJBObject if one has never been created.
 
Ådne Brunborg
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The client does not actually create the EJBObject by calling the EJBHome.create(), but rather asks for a reference to an instance of the EJBObject. If the container already has a session bean of this type available, then a reference to this is passed, if not a new one is created.

Only the container creates EJBObjects.
[ October 19, 2006: Message edited by: �dne Brunborg ]
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic