Change 20090905-sebastianwagner-d by
[email protected] on 2009-09-05 19:32:56
CEST
in
/Users/sebastianwagner/Documents/work/openlaszlo/branches/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: This Fixes: LPP-8437, LPP-8029
Extends Output of RPC with Gson as marshaller. This changeset adds a new
Factory Class to set a custom Json Marshaller
LZJsonFactory => to overwrite the default Json Handling you can call the
Method: LZJsonFactory.setJsonBuilderInstance(LZBaseJsonMarshallAdapter
instance)
There are two implementations of Json:
1) The existing, that I slightly refactored to fit into the Factory +
Adapter/Interface Pattern (LZJsonMarshaller)
2) The Gson Handling which is now the default one (LZGsonMarshaller)
To write your own Marshaller you have to use the pattern
public MyMarshaller extends LZBaseJsonMarshallAdapter implements
ILZJsonMarshaller {
public synchronized byte[] createObject(Object object, String
objectReturnType) {}
}
and then set an instance of that Object with
LZJsonFactory.setJsonBuilderInstance(myMarshallerInstanceObject)
The LZGsonMarshaller has some default settings to make the JSon Output 100%
equal to the existing one.
To disable that you should call:
LZGsonMarshaller.applyLzDefaultGsonProperties = false;
To get the Gson Factory to set your custom marshalling options you have to:
GsonBuilder gsonBuilder = LZGsonMarshaller.getGsonBuilderInstance()
=> using the gsonBuilder you then can set any property that is documented
at:
http://sites.google.com/site/gson/gson-user-guide
By using Gson you can then also use annotations or other manipulations to
modify the JSon output.
See their user guide for full documentation of features.
If Gson detects a Circular Reference it will throw for example:
ava.lang.IllegalStateException: Circular reference found:
org.i4change.app.hibernate.beans.user.us...@2855f16e
at
com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:108)
at
com.google.gson.JsonSerializationVisitor.getJsonElementForChild(JsonSerializationVisitor.java:117)
at
com.google.gson.JsonSerializationVisitor.addAsChildOfObject(JsonSerializationVisitor.java:95)
....
New Features:
Bugs Fixed: LPP-8437, Lpp-8029
Technical Reviewer: hqm
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
Tests:
Files:
A WEB-INF/lib/gson-1.3.jar
A
WEB-INF/lps/server/src/org/openlaszlo/remote/json/LZBaseJsonMarshallAdapter.java
A
WEB-INF/lps/server/src/org/openlaszlo/remote/json/ILZJsonMarshaller.java
A
WEB-INF/lps/server/src/org/openlaszlo/remote/json/LZGsonMarshaller.java
A WEB-INF/lps/server/src/org/openlaszlo/remote/json/LZJsonFactory.java
A
WEB-INF/lps/server/src/org/openlaszlo/remote/json/LZJsonMarshaller.java
M
WEB-INF/lps/server/src/org/openlaszlo/remote/json/LZReturnObject.java
M WEB-INF/lps/server/src/org/openlaszlo/data/JavaDataSource.java
Changeset:
http://svn.openlaszlo.org/openlaszlo/patches/20090905-sebastianwagner-d.tar
--
Sebastian Wagner
http://www.webbase-design.de
http://openmeetings.googlecode.com
http://www.laszlo-forum.de
[email protected]
_______________________________________________
Laszlo-reviews mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-reviews