return (Message) template.deserialize(mapper.readTree(bytes));
}
public <Message extends RexProMessage> byte[] serialize(Message message, Class<Message> messageClass) throws IOException {
RexProMessageTemplate template = null;
if (messageClass == ErrorResponseMessage.class) {
template = ErrorResponseMessageTemplate.getInstance();
} else if (messageClass == ScriptRequestMessage.class) {
template = ScriptRequestMessageTemplate.getInstance();
} else if (messageClass == ScriptResponseMessage.class) {
template = ScriptResponseMessageTemplate.getInstance();
} else if (messageClass == SessionRequestMessage.class) {
template = SessionRequestMessageTemplate.getInstance();
} else if (messageClass == SessionResponseMessage.class) {
template = SessionResponseMessageTemplate.getInstance();
}
JsonNode serialized = template.serialize(message);
return mapper.writeValueAsBytes(serialized);
}