java - how to "toString()" GWT EntityProxy derivatives for logging and debugging? -


gwt 2.1.1 has framework - requestfactory entityproxy , stuff.

i looking way serialize runtime instances implement entityproxy debugging , logging etc. not care format long human readable. more specific have provided apache commons lang reflectiontostringbuilder may there way use json serialization mechanics gwt has inside? if yes how make bit more readable?

import org.apache.commons.lang.builder.reflectiontostringbuilder;  string stringrep = reflectiontostringbuilder.tostring(this); 

there @ least 2 solutions:

first: based on idea thomas broyer

public static string tostring(entityproxy entityproxy) {     defaultproxystore store = new defaultproxystore();     swap.requestfactory.getserializer(store).serialize(entityproxy);     return store.encode(); } 

which produce this:

{"v":"211","p":{"1@2@biz.daich.swap.shared.dto.useraccountproxy":{"o":"persist","r":"2","y":1,"t":"biz.daich.swap.shared.dto.useraccountproxy","p":{"id":null,"items":null,"channelid":null,"lastactive":1296194777916,"name":null,"emailaddress":"test@example.com","lastreported":1296194777916,"lastloginon":1296194777916}}}} 

second: based on autobean framework

public static string tojson(entityproxy entityproxy) {     return autobeancodex.encode(autobeanutils.getautobean(entityproxy)).getpayload(); } 

which produce string

{"emailaddress":"test@example.com","lastactive":1296194777916,"lastloginon":1296194777916,"lastreported":1296194777916} 

the second need - more readable in log.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -