use of com.netflix.discovery.converters.jackson.AbstractEurekaJacksonCodec in project eureka by Netflix.
the class CodecLoadTester method createJacksonNgAction.
Func0 createJacksonNgAction(final MediaType mediaType, final boolean compact) {
return new Func0<Object>() {
@Override
public int call(Object object) {
AbstractEurekaJacksonCodec codec;
if (mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) {
codec = compact ? jsonCodecNgCompact : jsonCodecNG;
} else {
codec = compact ? xmlCodecNgCompact : xmlCodecNG;
}
ByteArrayOutputStream captureStream = new ByteArrayOutputStream();
try {
codec.writeTo(object, captureStream);
byte[] bytes = captureStream.toByteArray();
InputStream source = new ByteArrayInputStream(bytes);
Applications readValue = codec.getObjectMapper(object.getClass()).readValue(source, Applications.class);
secondHolder.value = readValue;
return bytes.length;
} catch (IOException e) {
throw new RuntimeException("unexpected", e);
}
}
};
}
Aggregations