This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Mastering Corda: Blockchain for Java Developers and have Jamiel Sheikh on-line!
See this thread for details.
Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

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
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic