• 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 on Sun Assessment Q07

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

7. Which statement characterizes stateful session beans?
Select only one
1) They allow the PostConstruct, PreDestroy, and PrePassivate life-cycle callbacks.
2) They require home interfaces.
3) When a client looks up a stateful session bean in the JNDI, the same bean is returned every time.
4) They are asynchronous message consumers.



Correct answer is 1.
I agree that 1 is a correct, but can someone explain me why 3 is incorrect

Regards
Cham
 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chaminda,

1 reason that comes to my mind for 3rd incorrect answer is-
---------------
When a client looks up a stateful session bean in the JNDI, the same bean is returned every time.
---------------

As the container maintain's a pool of Session Bean's, so when the same client do look up's again and again, it's not guranteed the container may return the same bean from the pool everytime.

Hope it clears.!
 
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
Stateful session beans are not pooled. A new session bean will be instantiated for each client requesting it from JNDI. It would not be useful if a client could not instantiate two different stateful session beans of the same class, would it ?
 
Chaminda Amarasinghe
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I agree to Christophe ,

So why option 3 is incorrect
 
Christophe Verré
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

So why option 3 is incorrect


The answer says : the same bean is returned every time. Incorrect, a difference bean (instance) is returned.
 
Chaminda Amarasinghe
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you talking about a situation for different clients or for same client?

Answer says "a client", isnt that same client?
 
Christophe Verré
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
I'm talking of the same client.
 
Chaminda Amarasinghe
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you are saying different bean returned for same client, I cant agree to that.

If how SFSB keeps clients state?
 
Christophe Verré
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
Make a stateful session bean, with one setter method. From the same client, grab the bean twice from JNDI. What is going to happen ?



Unlike stateless session beans, the state is preserved between method calls. It doesn't mean there is only one bean per client.
 
Chaminda Amarasinghe
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Dude, clearing me.
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

So why option 3 is incorrect

I think the option refers to the identity of ejb's in the client view. That is compared with "equals" [e.g. ejb1.equals(ejb2) ] and says wether two ejb's are meaningfully (!) identical. If you lookup two stateless session beans of the same type, they are allways "equal", while stateful session beans are never.
[ November 19, 2008: Message edited by: Ralph Jaus ]
 
Chaminda Amarasinghe
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ralph, Christophe and others
reply
    Bookmark Topic Watch Topic
  • New Topic