Hello all!

I'm working on a project where a need to serialize objects for the
client without using RPC/RemoteService.
My code works fine for standard objects when using
String encoded = RPC.encodeResponseForSuccess(method, bundle);
(default serializing policy)

or when loading my service's custom serializing policy by:

SerializationPolicyLoader.getSerializationPolicyFileName(path + name);

But it only works when I know the name of the gwt.rpc serializing
policy file. I would very much like a solution where I could read the
CRC string (strongName) of the current policy used by RPC's
ServerSerializingStreamReader. But as it seems, the GWT team has gone
through extend lengths to ensure this is not possible, and I can only
come as close as:
com.google.gwt.user.server.rpc.RPC:252:
SerializationPolicy serializationPolicy =
streamReader.getSerializationPolicy();

So I end up with something like this:

Method targetMethod = MyService.class.getMethod("helloWorld", new
Class[0]);
MySerializedPOJO bundle = new MySerializedPOJO();
ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
SerializationPolicyProvider serializationPolicyProvider = new
MyServiceImpl();
ServerSerializationStreamReader reader = new
ServerSerializationStreamReader(classLoader,
serializationPolicyProvider);
return RPC.encodeResponseForSuccess(targetMethod, bundle,
reader.getSerializationPolicy());

By assuming that MyServiceImpl extends RemoteService and therefore
should know the correct policy.
But this still returns the default serialization policy (I guess?) and
cause:
SerializationException: MySerializedPOJO is not assignable to
'com.google.gwt.user.client.rpc.IsSerializable' and did not have a
custom field serializer.


What approach should I use to get the correct serialization policy for
MyService?

Best regards
Troels Nørgaard

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

Reply via email to