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
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.
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()
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.
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
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.