Stateful Session Bean with CMT can implement SessionSynchronization interface.
Stateful BMT and Stateless CMT/BMT beans are not allowed to.
[Refer tables number 2 and 3 in the
ejb spec]
Originally posted by Chandra Vadlamani:
how does it matter if a bean is stateless or stateful, DD is the one which governs the scope and the smallest scope is method level.
There are some session beans which can be deployed as stateful or stateless. But not all. Like if there is a session bean which has create() methods with arguments, there is no chance that this bean can be deployed as a stateless session bean.
The choice of whether a bean should be a statless OR stateful session bean depends on the business logic and generally a few beans will be in a category where the deployer needs to change the statefulness/statelessness.
In cases in which one is sure that a bean will not be and cannot be deployed as a stateless session bean, SessionSynchronization interface can be implemented, if needed.
Regards,
Leena