Netflix/curator — pull request #210 by dougnukem (2012-11-23 21:31:10+00:00)
Title: GenericDiscoveryContext to simplify custom ServiceInstance payload types

Added GenericDiscoveryContext to make it simpler to implement a custom ServiceInstance payload context in the REST discovery server.

More details on motivation for the suggested change:
- https://groups.google.com/forum/?fromgroups=#!topic/curator-users/k5ioCwr_fi4

GenericDiscoveryContext is essentially using ObjectMapper to read from the JsonNode representing the payload and using ObjectNode putPOJO() to write:

```java

public T unMarshallJson(JsonNode node) throws Exception
{
//...
T payload;
ObjectMapper mapper = new ObjectMapper();
payload = (T) mapper.readValue(node, payloadType);
return payload;
}

public void marshallJson(ObjectNode node, String fieldName, T payload) throws Exception
{
//...
node.putPOJO(fieldName, payload);
//...
}
```

Related changes also include:

- Migrated MapDiscoveryContext to extend GenericDiscoveryContext.
- Added corresponding unit tests for TestObjectPayloadWithJersey