RPC Serialize: set filter at runtime to select fields to serialize

23 views
Skip to first unread message

saul

unread,
Aug 28, 2011, 11:40:50 AM8/28/11
to Google Web Toolkit
I am trying to find a way to control, during runtime, what members of
an object are RPC serialized at the server. For example, say we have a
POJO and an server side access control filter that only grants access
to certain fileds of the object. Resolving the access rights of the
request may require us to hide certain fields' values from the
response differently for different requests. One may suggest to simply
set the fileds that are not accessible to null before returning the
object, but this wil pose issue with persistant, cached or immutable
POJOs. Further, a feature such as lazy-loading in hibernate becomes
difficult to manage without the using DTO. Using DTO or cloning an
object is possible but inefficient in the programming model.

Is there a way that at runtime, one can set a serialization filter
such that any fileds that are defined in the filter will not be
accessed during serialization (and hence will not trigger a lazy load)
on the server an instead will be serialized as nulls?

The particular flow is something like:

RPC client request -> deserialize on server -> request access control
logic -> request data filter -> app logic -> response access control
logic -> response data filter -> serialize response



Juan Pablo Gardella

unread,
Aug 28, 2011, 5:23:34 PM8/28/11
to google-we...@googlegroups.com
Do you see gilead and transport annotations? For me is intrusive but perhaps its help to you. I like use filters instead, you can see in this sample.

Juan

2011/8/28 saul <sauls...@gmail.com>



--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Saul Simhon

unread,
Aug 28, 2011, 7:36:44 PM8/28/11
to google-we...@googlegroups.com
Thank you. Interesting. Well, the gilead annotations are useless to me
since they are not runtime parameters. The code you posted looks
interesting. I will play with it. Ideally, the controller can compute
or inject a list of property names (field names), or a map of property
names with filter qualifiers, that is then used to filter the
serialization. I did not see anything like this in your code, but will
take a closer look!

Alex Dobjanschi

unread,
Aug 29, 2011, 3:37:29 AM8/29/11
to google-we...@googlegroups.com, sauls...@gmail.com
I would go with DTO. From your post, I get that you don't want lazy-load -- if that's so, why don't you disable it? http://docs.jboss.org/hibernate/core/3.3/reference/en/html/performance.html#performance-fetching
Reply all
Reply to author
Forward
0 new messages