dia100 wrote:
There's one _big_ caveat if using session beans. I learned this while moving my code from using only Hibernate beans to using Hibernate beans plus sessions beans.
Well, that caveat applies to all remote services that transfer persistent objects: You've got call-by-value instead of call-by-reference then, not propagating changes from the service back to the caller. Not only remote EJBs but also plain RMI, Hessian, Burlap, SOAP Web Services, etc are affected here.
However, this does
not apply to logical services that are by their nature kept locally within the same VM, be it local EJBs or Spring-managed business objects. Their service interfaces can assume call-by-reference, and be as fine-grained as appropriate from a business perspective. Why worry about remote semantics as long as just calling objects locally anyway?
So what I usually recommend is to define everything as logical POJO business objects in the first place, as many applications will never need to export a remote service. If you ever encounter the need for remoting, export a corresponding business object as remote service (provided that its natural interface already matches remote semantics), or implement a thin remote service wrapper for corresponding business objects.
As you might have guessed, this middle tier design philosophy is central to the Spring Framework: It provides all the means necessary for it, from wiring POJO layers and declarative transactions on POJOs to remote exporters and remote proxy factory beans. Currently, the out-of-the-box remoting options are Hessian, Burlap, JAX-RPC, and RMI - as illustrated by our new JPetStore version.
Juergen
(Spring Framework developer)