I knew that with state preservation, beans supports a conversational session between different calls to the instance method, but without apathy it will not. My question is suppose I have a beanless implementation as shown below
import javax.ejb.Stateful; import javax.ejb.Stateless; import com.tata.ejb3.data.HelloEJBInterface; @Stateless public class ValueEJB implements ValueEJBInterface{ private int value; @Override public int getValue() { return this.value; } @Override public void setValue(int value) { this.value = value; } }
I have my bean client (servlet) that initiates a bean call as shown below
@EJB(mappedName="E/ValueEJB /remote") ValueEJBInterface value; .... value.setValue(250); System.out.println(value.getValue());
According to my understanding, since my bean is a stateless bean, it should not be displayed with a value of 250.
private int value; - this is an instantaneous variable, if one of the methods without saving the set value, the value will expire when the method exits. But here I can get the value "250" even through my second method call. Is this a violation of the stateless concept? Am I missing something?
source share