Search in sources :

Example 1 with MsgPackSimpleSerializer

use of com.tvd12.ezyfox.codec.MsgPackSimpleSerializer in project calabash by youngmonkeys.

the class LocalMapPersistExample method newEntityCodec.

protected EzyEntityCodec newEntityCodec() {
    EzyBindingContext bindingContext = EzyBindingContext.builder().scan("com.tvd12.calabash.server.core.test.localmappersit").build();
    EzyMessageSerializer messageSerializer = new MsgPackSimpleSerializer();
    EzyMessageDeserializer messageDeserializer = new MsgPackSimpleDeserializer();
    return EzyBindingEntityCodec.builder().marshaller(bindingContext.newMarshaller()).unmarshaller(bindingContext.newUnmarshaller()).messageSerializer(messageSerializer).messageDeserializer(messageDeserializer).build();
}
Also used : EzyBindingContext(com.tvd12.ezyfox.binding.EzyBindingContext)

Example 2 with MsgPackSimpleSerializer

use of com.tvd12.ezyfox.codec.MsgPackSimpleSerializer in project ezyfox-examples by tvd12.

the class MsgpackExample method main.

public static void main(String[] args) {
    final EzyBindingContext bindingContext = EzyBindingContext.builder().scan("com.tvd12.ezyfox.example.msgpack").build();
    final EzyEntityCodec codec = EzyBindingEntityCodec.builder().marshaller(bindingContext.newMarshaller()).unmarshaller(bindingContext.newUnmarshaller()).messageSerializer(new MsgPackSimpleSerializer()).messageDeserializer(new MsgPackSimpleDeserializer()).build();
    final Transfer transfer = new Transfer(300, 100);
    final byte[] serializedBytes = codec.serialize(transfer);
    System.out.println(serializedBytes.length);
    System.out.println(Arrays.toString(serializedBytes));
    System.out.println(EzyPrints.printHex(serializedBytes));
    final Transfer deserializedObj = codec.deserialize(serializedBytes, Transfer.class);
    System.out.println(deserializedObj);
}
Also used : EzyBindingContext(com.tvd12.ezyfox.binding.EzyBindingContext) MsgPackSimpleSerializer(com.tvd12.ezyfox.codec.MsgPackSimpleSerializer) MsgPackSimpleDeserializer(com.tvd12.ezyfox.codec.MsgPackSimpleDeserializer) EzyEntityCodec(com.tvd12.ezyfox.codec.EzyEntityCodec)

Aggregations

EzyBindingContext (com.tvd12.ezyfox.binding.EzyBindingContext)2 EzyEntityCodec (com.tvd12.ezyfox.codec.EzyEntityCodec)1 MsgPackSimpleDeserializer (com.tvd12.ezyfox.codec.MsgPackSimpleDeserializer)1 MsgPackSimpleSerializer (com.tvd12.ezyfox.codec.MsgPackSimpleSerializer)1