Package com.tinkerpop.rexster.protocol.serializer.json.templates.messages

Examples of com.tinkerpop.rexster.protocol.serializer.json.templates.messages.RexProMessageTemplate


    private static ObjectMapper mapper = new ObjectMapper();

    public <Message extends RexProMessage> Message deserialize(byte[] bytes, 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();
        }

        return (Message) template.deserialize(mapper.readTree(bytes));
    }
View Full Code Here


        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);
    }
View Full Code Here

TOP

Related Classes of com.tinkerpop.rexster.protocol.serializer.json.templates.messages.RexProMessageTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.