• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Session Bean Doubt

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Which statements about stateful and stateless session beans are true?
(Choose all that apply.)

a). Only stateful session beans support transactions.
b). Only stateful session beans can be passivated.
c). Only stateful session beans have a 'setSessionContext' method.
d). Both stateful and stateless session beans can support
overloaded 'ejbCreate' methods.
e). Both stateful and stateless session beans can implement
the 'javax.ejb.SessionSynchronization' interface.
f). Both stateful and stateless session beans can have instance variable state.

ans given : b,f - how a stateless session bean can have state in an instance variable.
my answer : b
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Karthikeyan,
answers B and F are correct. session conversational state is different from instance variables state. but in stateless session bean, if you declare any instance variables, becareful in handling them. or you will see unwanted results.

thanks,
Ugender
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also see this thread
 
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not clear about option b.
stateless session beans can also be passivated but their passivation is not required and in their normal lifecycle their passivation is not required.
**and one more,in all types of beans we have to define ejbPassivate()
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Raj, I'm not sure I agree with you. Although those beans inherit those methods from javax.ejb.SessionBean, they are never called in a stateless session bean. Stateless beans are "awake" as they sit in the instance pool so there is no need to wake them up (ejbActivate())or put them to sleep (ejbPassivate()). Also, they do not keep conversational state so there is no need to use these methods no reload the instance with the related client. If you have HF EJB, pg 223 has the lifecycle diagram for both stateful and stateless session beans.

HTH
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree that the answers are b and f.
Raj, the stateless session bean never get a call to passivate and activate. they are there in the SessionBean just because there is only one common interface be it stateful or stateless.
Stateless session bean never gets passivated
 
Won't you be my neighbor? - Fred Rogers. tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic