aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Doubt from the Specs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Doubt from the Specs" Watch "Doubt from the Specs" New topic
Author

Doubt from the Specs

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

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!


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

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


SCJP, SCJD, SCWCD, OCPJBCD
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

I still coudn't get it!
Mirko Bonasorte
Ranch Hand

Joined: May 14, 2007
Posts: 244
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.


SCJP<br />SCWCD 1.4 Upgrade (Remember: me stupid)<br />SCWCD 1.4<br /><a href="http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html" target="_blank" rel="nofollow">SCBCD 5.0</a><br /><a href="http://www.enthuware.com" target="_blank" rel="nofollow">SCBCD 5.0 mock exam</a> <br /> <br />SCEA 5 Part1: Preparing...
Nitin Takale
Greenhorn

Joined: Nov 30, 2006
Posts: 26
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


Nitin<br /> <br />SCJP 6.0<br />SCBCD 5.0
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

After a long time I had to go through the specs and now I can manipulate what you have explained above. Thanks!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

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

Joined: Sep 26, 2006
Posts: 9427
    
    2

By the way is there anyone here who can provide some hints on some App servers that are 100% EJB 3 spec compliant?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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 ]

[My Blog]
All roads lead to JavaRanch
 
Consider Paul's rocket mass heater.
 
subject: Doubt from the Specs