serialization manager now uses generics for determining IO buffer type
This commit is contained in:
parent
8c78e59bf3
commit
131443e110
@ -23,10 +23,8 @@ import com.esotericsoftware.kryo.Serializer;
|
|||||||
import com.esotericsoftware.kryo.io.Input;
|
import com.esotericsoftware.kryo.io.Input;
|
||||||
import com.esotericsoftware.kryo.io.Output;
|
import com.esotericsoftware.kryo.io.Output;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
|
|
||||||
public
|
public
|
||||||
interface SerializationManager {
|
interface SerializationManager<IO> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the class using the lowest, next available integer ID and the {@link Kryo#getDefaultSerializer(Class) default serializer}.
|
* Registers the class using the lowest, next available integer ID and the {@link Kryo#getDefaultSerializer(Class) default serializer}.
|
||||||
@ -79,20 +77,16 @@ interface SerializationManager {
|
|||||||
/**
|
/**
|
||||||
* Waits until a kryo is available to write, using CAS operations to prevent having to synchronize.
|
* Waits until a kryo is available to write, using CAS operations to prevent having to synchronize.
|
||||||
* <p/>
|
* <p/>
|
||||||
* No crypto and no sequence number
|
|
||||||
* <p/>
|
|
||||||
* There is a small speed penalty if there were no kryo's available to use.
|
* There is a small speed penalty if there were no kryo's available to use.
|
||||||
*/
|
*/
|
||||||
void write(ByteBuf buffer, Object message) throws IOException;
|
void write(IO buffer, Object message) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads an object from the buffer.
|
* Reads an object from the buffer.
|
||||||
* <p/>
|
|
||||||
* No crypto and no sequence number
|
|
||||||
*
|
*
|
||||||
* @param length should ALWAYS be the length of the expected object!
|
* @param length should ALWAYS be the length of the expected object!
|
||||||
*/
|
*/
|
||||||
Object read(ByteBuf buffer, int length) throws IOException;
|
Object read(IO buffer, int length) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes the class and object using an available kryo instance
|
* Writes the class and object using an available kryo instance
|
||||||
|
@ -27,7 +27,7 @@ import dorkbox.util.serialization.SerializationDefaults;
|
|||||||
import dorkbox.util.serialization.SerializationManager;
|
import dorkbox.util.serialization.SerializationManager;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
class DefaultStorageSerializationManager implements SerializationManager {
|
class DefaultStorageSerializationManager implements SerializationManager<ByteBuf> {
|
||||||
private Kryo kryo = new Kryo() {{
|
private Kryo kryo = new Kryo() {{
|
||||||
// we don't want logging from Kryo...
|
// we don't want logging from Kryo...
|
||||||
Log.set(Log.LEVEL_ERROR);
|
Log.set(Log.LEVEL_ERROR);
|
||||||
|
Loading…
Reference in New Issue
Block a user