Updatable Transfer Objects and remote EJB interfaces
posted 7 years ago
The use of transfer Objects with EJBs is a common approach, and the use of updatable transfer Objects is not uncommon. However I hit two problems on JBoss 5 that I haven't encountered or seen discussed before.
In short, the instance of a transfer object (TO) passed to a bean as a method argument via a remote interface is not the same instance on which the bean will operate (because it has been marshalled, and a new instance has been created by the skeleton).
This has two implications:
the client's original TO will not reflect any changes to properties made by the bean.
if a propertyChanged interface (Observer) is employed, registered listeners will not be notified.
Of course, neither of these is an issue if local interfaces are used. Does anyone know if this difference in behavior (the passing of references, generally, via remote interfaces) is documented in the spec, and if so, whether JBoss 5 is compliant?
In our case, the latency problem was solved by modifying the appropriate bean methods to return an updated TO, and we implemented a mechanism to queue the property change events so as to defer notification. So, we don't have a problem, but I'm curious why I haven't seen these issues discussed anywhere.