Hi Can any one tell me how do i differentiate looking at the code if the code is for stateless or stateful bean in j2ee/ejb environment. I know the entry in xml file helps in doing this but other then this is there any difference in the code. Thanks Harsh
i am new to ejb , but I think without knowing the intent of the code , it would be almost impossible to say whether this particular bean can be stateful or stateless, i mean the only difference as i see is that if you can re initialize the bean to its earlier state it essentially would end up being a stateful bean ? wouldn't it ?(ignoring the fact of course that activation/passivation wont' occur) and you manage to do it in your code without the containers help to achieve statefulness ?
You can't tell from the code (unless the bean implements the SessionSynchronization interface, in which case you know it's stateful, but that's a rare case). The only way to know is by looking at the deployment descriptor. Kyle
There is difference in the ejbCreate method signature. The ejbCreate method of stateless session bean is empty where as that of stateful session bean is not. The other difference is in the deployment descriptor.
posted 17 years ago
Originally posted by Parsuram panigrahi: There is difference in the ejbCreate method signature. The ejbCreate method of stateless session bean is empty where as that of stateful session bean is not. The other difference is in the deployment descriptor.
Actually, it is possible to have a stateful session bean with an empty ejbCreate() signature, too, which is why I didn't bring it up. But you're right that if you find an ejbCreate() and ejbPostCreate() signature that's not empty then it's a sure sign it's a stateful bean. Kyle [ March 18, 2003: Message edited by: Kyle Brown ]