GWT Atmosphere + RequestFactory

I would like to create the following behavior:

The user saves an object in the browser. After the object is saved on the server side, it generates a notification and must notify all other clients via Atmosphere with the updated entity instance.

So the problem is how can I push the POJO object through the Atmosphere interface ? The latter supports Serializable types for transmission over wires, while RequestFactory has a different serialization mechanism.

So I need to convert the POJO to autobean as this is done by RF and sent to client. Does anyone know how this can be done?

+3


source to share


1 answer


You can just use AutoBeans creation and use them instead of POJOs in your client code. AutoBeans can be easily serialized to / from JSON to GWT and JSON can be transported. This is what I am doing in my websocket based GWT application.

On the server, you can create the same AutoBean factory that you use on the client. Instead of GWT.create, we use AutoBeanFactorySource:



MyDataFactory factory = AutoBeanFactorySource.create(MyDataFactory.class)
AutoBean<MyData> myDataAutoBean = factory.myData();
MyData data = myDataAutoBean.as();
data.setValue(1); // call all kinds of setters

// to converto AutoBean to JSON
String json = AutoBeanCodex.encode(myDataAutoBean).getPayload();

      

On the client side we are using AutoBeanCodex to decode json in AutoBean

+7


source







All Articles