Object instances / serialization in Scout offline-applications [message #1262384] |
Mon, 03 March 2014 10:26  |
Eclipse User |
|
|
|
We have a Scout application where client and server run in the same VM / process (Scout "offline"-deployment). During development we've noticed a strange behavior: when a server-side method has changed an object property, a PropertyChange event has been fired and caused a change in the GUI which caused an Exception since the method of Swing widget was called by the server-thread.
Now, how could it come to this situation? When a Scout application runs in a typical client/server deployment, all objects returned from a server-side methode are serialized and de-serialized on the client. But when Scout server runs offline, de-/serialization is not performed at all. This means, when we have dummy code like this:
// server
public Foo loadFoo() {
return Session.get().getFoo();
}
// client
public void execLoad() {
Foo foo = SERVICES.getService(IFooService.class).loadFoo();
}
In offline-mode only one instance of Foo exists in the VM, which means, when you change the object Foo on the server-side, it also changes the Object on the client-side! In online-mode however, there are two instances of Foo because serialization is applied. Obviously server-side changes do not affect the instance on the client-side at all.
Additionally, since Scout does not serialize objects in offline-mode, you'll never notice when an object is not Serializable.
My question is: is this intended behavior? Should I build code which relies on this behavior? Of course, it is technically not necessary to serialize objects when client and server run in the same VM. However, in my opinion Scout should perform serialization in offline-mode to detect and avoid problems as described above and to be consistent with the behavior you have, when you deploy the same server-component in a real client/server deployment.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07337 seconds