Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException, WebApplicationException {
FudgeMsgEnvelope msg;
if (obj instanceof FudgeResponse) {
FudgeResponse wrapper = (FudgeResponse) obj;
msg = getFudgeContext().toFudgeMsg(wrapper.getValue());
} else if (obj instanceof FudgeMsgEnvelope) {
msg = (FudgeMsgEnvelope) obj;
} else if (obj instanceof FudgeMsg) {
msg = new FudgeMsgEnvelope((FudgeMsg) obj);
} else {
msg = getFudgeContext().toFudgeMsg(obj);
}
OutputStreamWriter entityWriter = new OutputStreamWriter(entityStream, Charsets.UTF_8);