!cdd #17770 Use self recursive type in AbstractReplicatedData (Java API)
* complete the TwoPhaseSet java sample with serialization
This commit is contained in:
parent
49e6e7f38c
commit
da07a2e68e
9 changed files with 315 additions and 26 deletions
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* Copyright (C) 2015 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
package docs.ddata.japi.protobuf;
|
||||
|
||||
import docs.ddata.japi.TwoPhaseSet;
|
||||
|
||||
import akka.actor.ExtendedActorSystem;
|
||||
|
||||
public class TwoPhaseSetSerializerWithCompression extends TwoPhaseSetSerializer {
|
||||
public TwoPhaseSetSerializerWithCompression(ExtendedActorSystem system) {
|
||||
super(system);
|
||||
}
|
||||
|
||||
//#compression
|
||||
@Override
|
||||
public byte[] toBinary(Object obj) {
|
||||
if (obj instanceof TwoPhaseSet) {
|
||||
return compress(twoPhaseSetToProto((TwoPhaseSet) obj));
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"Can't serialize object of type " + obj.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object fromBinaryJava(byte[] bytes, Class<?> manifest) {
|
||||
return twoPhaseSetFromBinary(decompress(bytes));
|
||||
}
|
||||
//#compression
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue