@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
@JsonTypeIdResolver(EventTypeIdResolver.class)
public interface IEvent {
}
I created a resty resolver like this:
public class EventTypeIdGeneratorResty implements RestyJsonTypeIdResolver {
private final static Map<String, Class<?>> TYPE_MAP;
static {
TYPE_MAP = Maps.newHashMap();
TYPE_MAP.put(MessageLoad.class.getName(), MessageLoad.class);
TYPE_MAP.put(MessageHandled.class.getName(), MessageHandled.class);
}
@Override
public Class<? extends TypeIdResolver> getTypeIdResolverClass() {
return EventTypeIdResolver.class;
}
@Override
public Map<String, Class<?>> getIdClassMap() {
System.out.println("getIdClassMap is called during GWT compilation");
return TYPE_MAP;
}
}
And I have the following in my application gwt.xml file: (sorry paste in groups on IE11 seems to be really bad, it does not allow me to remove these magic whitespace that are not in the orginal)
<inherits name="org.fusesource.restygwt.RestyGWT"/>
<extend-configuration-property
name="org.fusesource.restygwt.jsontypeidresolver"
value="
com.acme.cloud.ui.demo.server.api.EventTypeIdGeneratorResty"
/>
when I compile (using mvn) I don't see the System.out so I guess the class is not used at all.
the compiler gives me:
Adding '5' new generated units
[INFO] Tracing compile failure path for type 'com.acme.cloud.event.msghandler.MessageLoad_Generated_JsonEncoderDecoder_'
[INFO] [ERROR] Errors in 'generated://61A2FB0EF300D37B474A4C68DC94E3C1/com/acme/cloud/event/msghandler/MessageLoad_Generated_JsonEncoderDecoder_.java'
[INFO] [ERROR] Line 7: This method must return a result of type JSONValue
[INFO] [ERROR] Line 14: This method must return a result of type MessageLoad
[INFO] See snapshot: C:\Users\dnouls\AppData\Local\Temp\com.acme.cloud.event.msghandler.MessageLoad_Generated_JsonEncoderDecoder_9174915194281980093.java
[INFO] [ERROR] Errors in 'generated://61A2FB0EF300D37B474A4C68DC94E3C1/com/acme/cloud/event/msghandler/MessageLoad_Generated_JsonEncoderDecoder_.java'
[INFO] [ERROR] Line 7: This method must return a result of type JSONValue
[INFO] [ERROR] Line 14: This method must return a result of type MessageLoad
[INFO] See snapshot: C:\Users\dnouls\AppData\Local\Temp\com.acme.cloud.event.msghandler.MessageLoad_Generated_JsonEncoderDecoder_1156780688736935193.java
[INFO] Tracing compile failure path for type 'com.acme.cloud.event.msghandler.MessageLoad_Generated_JsonEncoderDecoder_'
[INFO] [ERROR] Errors in 'generated://61A2FB0EF300D37B474A4C68DC94E3C1/com/acme/cloud/event/msghandler/MessageLoad_Generated_JsonEncoderDecoder_.java'
[INFO] [ERROR] Line 7: This method must return a result of type JSONValue
[INFO] [ERROR] Line 14: This method must return a result of type MessageLoad
[INFO] [ERROR] Hint: Check that the type name 'com.acme.cloud.event.msghandler.MessageLoad_Generated_JsonEncoderDecoder_' is really what you meant
[INFO] [ERROR] Hint: Check that your classpath includes all required source roots
The generated files look like this:
package com.acme.cloud.event.msghandler;public class MessageLoad_Generated_JsonEncoderDecoder_ extends org.fusesource.restygwt.client.AbstractJsonEncoderDecoder<com.acme.cloud.event.msghandler.MessageLoad> {
public static final MessageLoad_Generated_JsonEncoderDecoder_ INSTANCE = new MessageLoad_Generated_JsonEncoderDecoder_();
public com.google.gwt.json.client.JSONValue encode(com.acme.cloud.event.msghandler.MessageLoad value) {
if( value==null ) {
return getNullType();
}
com.google.gwt.json.client.JSONObject rc = new com.google.gwt.json.client.JSONObject();
}
public MessageLoad decode(com.google.gwt.json.client.JSONValue value) {
if( value == null || value.isNull()!=null ) {
return null;
}
com.google.gwt.json.client.JSONObject object = toObject(value);
}
}
What I am missing ?
...
@JsonCreator
public Id(String pId) {
Preconditions.checkNotNull(pId);
mId = pId;
}
@JsonValue
public String getId() {
return pId;
}
We often do this in our java classes to enforce typesafety, but in the Json output we only see the string.
However RestyGWT seems to assume that a JsonCreator is supposed to have a JsonProperty on all the creator parameters.
Jackson does not require this.
I saw your issue on github - will look into this
--
You received this message because you are subscribed to the Google Groups "RestyGWT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to restygwt+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.