Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of the IsSerializable interface in GWT (regarding the RPC mechanism)

Tags:

What is the purpose of the IsSerializable interface in GWT (regarding the RPC mechanism). I have never been able to find a good explanation as to why it is the way it is and why the default Java Serializable tagging interface does not work.

like image 403
benstpierre Avatar asked Jun 17 '10 19:06

benstpierre


People also ask

How does GWT RPC work?

GWT RPC is servlet based. GWT RPC is asynchronous and client is never blocked during communication. Using GWT RPC Java objects can be sent directly between the client and the server (which are automatically serialized by the GWT framework). Server-side servlet is termed as service.

What is GWT client?

GWT contains a number of HTTP client classes that simplify making custom HTTP requests to your server and optionally processing a JSON- or XML-formatted response. GWT contains a set of HTTP client classes that allow your application to make generic HTTP requests.


1 Answers

Both Serializable and IsSerializable work, according to the GWT serialization docs:

A user-defined class is serializable if all of the following apply:

  1. It is assignable to IsSerializable or Serializable, either because it directly implements one of these interfaces or because it derives from a superclass that does
  2. All non-final, non-transient instance fields are themselves serializable, and
  3. As of GWT 1.5, it must have a default (zero argument) constructor (with any access modifier) or no constructor at all.

One key difference though is that , for security reasons, all Serializable classes must be included in a serialization policy, which is generated at compile time, while IsSerializable classes do not have that requirement.

If your interest is purely in GWT, and you don't e.g. share your model classes between the web application and another application, I suggest you have your model classes/DTOs implement IsSerializable.

like image 171
Robert Munteanu Avatar answered Sep 20 '22 11:09

Robert Munteanu