Skip to content
This repository has been archived by the owner on Nov 14, 2022. It is now read-only.

Koboo/serialization

Repository files navigation

Binflux-Serialization

Serialization implements different Java serialization libraries into a pool to serialize or deserialize objects in byte arrays easily & quickly.

Overview

Usage

Creating a new SerializerPool instance using standard JavaSerialization.class:

SerializerPool pool = new SerializerPool(JavaSerialzation.class);

String string = new String("Lorem ipsum dolor sit amet.");
    
byte[] serialized = pool.serialize(string);
    
String deserialized = pool.deserialize(serialized);

If something goes wrong during de- or serialization, the exception is thrown and instead of the object you get null.

Implemented Serialization

Serialization (Class) Serialization (Framework)
KryoSerialization Kryo
KryoUnsafeSerialization Kryo
JavaSerialization Java I/O
FSTSerialization fast-serialization
FSTNoSharedSerialization fast-serialization
HessianSerialization Hessian
Hessian2Serialization Hessian
QuickserSerialization QuickSer
ElsaSerialization Elsa
ElsaStreamSerialization Elsa

Frameworks:

Implement Serialization

Implementing a new Serialization:

public class CustomSerialization implements Serialization {
    
    @Override
    public <T> byte[] serialize(T object) {
        // Serialization workflow here
    }

    @Override
    public <T> T deserialize(byte[] bytes) {
        // Deserialization workflow here
    }
} 

Add as dependency

Add repo.koboo.eu as repository.

repositories {
    maven { url 'https://repo.koboo.eu/releases' }
}

And add specific serializer as dependency. (e.g. 1.0 is the release-version)

dependencies {
    // !Always needed!
    compile 'eu.koboo:serial-core:1.0'
    // Select specific serializer
    compile 'eu.koboo:serial-elsa:1.0'
    compile 'eu.koboo:serial-fst:1.0'
    compile 'eu.koboo:serial-hessian:1.0'
    compile 'eu.koboo:serial-kryo:1.0'
    compile 'eu.koboo:serial-quickser:1.0'
}

Build from source

  • Clone repository
  • Run ./gradlew buildApp
  • Output /build/libs/serialization-{version}-all.jar
  • Build task build.gradle