• 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

Doubt from the Specs

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The below quote is form the specs,

Since stateless session bean instances are typically pooled, the time of the client's invocation of the create method need not have any direct relationship to the container's invocation of the PostConstruct/ejbCreate method on the stateless session bean instance.



I'm failing to understand this. Please help guys!
 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jothi

any method from your business interface does not need to relay on the PostConstruct method. Something like one bussines method will fail if the PostConstruct method(s) does not runs before.

I also think that the same logic for the pasivate feature (callback)

Regards,
M
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still coudn't get it!
 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See specs paragraph 4.5.1
The stateless session beans are pooled. This means that:
1. You don't know when PostConstruct method is called
2. If an instance of your bean is reused for another client, the callback method will not be called

This means that your PostConstruct invokation cannot safely access to informations related to a specific request.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jyoti,

Stateless Session Beans are pooled. So think.. when the instances of bean class are getting created... as soon as you deploy the bean.

Now when you deploy the bean the container how it is creating the instance of bean class that is given to it ???

first it (container) loads the bean class
then it calls.. Class.newInstance() to create the object of bean...
then it calls ... setSessionContext if it is there..
then it calls... any method annotated with postConstruct or ejbCreate if it is there...

now bean pool is ready..

After this (it means after deployment of bean) client is free to call method on bean.

now even if a ejb 2.0/2.1 client... (their home interface has create method).. does lookup on homeObject and then calls create() on that home object (which according to ejb 2.0/2.1 specs is going to return reference of remote / local interface ..) the container is not going to create new bean instance so it is not going to call any postConstruct or ejbCreate method on bean.

That's what the specs is saying.


(There are some other details which you'll get to know later on as you progress)

I hope this is sufficient for you.

bye

nitin
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After a long time I had to go through the specs and now I can manipulate what you have explained above. Thanks!
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But don't anyone feel that the particular paragraph that I posted above form the specs are a bit confusing?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way is there anyone here who can provide some hints on some App servers that are 100% EJB 3 spec compliant?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But don't anyone feel that the particular paragraph that I posted above form the specs are a bit confusing?


Yes, it may be difficult to understand if you are only used to EJB3's marvelous injection system, because things are done in the background. So "client's invocation of the create method" sounds obscure. If you know about EJB2.X, the way to use home interfaces to create beans, then what's written in the spec becomes clear.
[ September 04, 2008: Message edited by: Christophe Verre ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic