use of org.eclipse.ecf.core.sharedobject.util.ISharedObjectMessageSerializer in project ecf by eclipse.
the class SendSharedObjectMessageWithCustomSerializerTest method setUp.
protected void setUp() throws Exception {
super.setUp();
createServerAndClients();
connectClients();
// Setup custom serializer
ISharedObjectContainer soContainer = getClientSOContainer(0);
soContainer.setSharedObjectMessageSerializer(new ISharedObjectMessageSerializer() {
public Object deserializeMessage(byte[] data) throws IOException, ClassNotFoundException {
return deserialize(data);
}
public byte[] serializeMessage(ID sharedObjectId, Object message) throws IOException {
return serialize(message);
}
});
ISharedObjectContainer serverContainer = getServerSOContainer();
serverContainer.setSharedObjectMessageSerializer(new ISharedObjectMessageSerializer() {
public Object deserializeMessage(byte[] data) throws IOException, ClassNotFoundException {
return deserialize(data);
}
public byte[] serializeMessage(ID sharedObjectId, Object message) throws IOException {
return serialize(message);
}
});
// Add test messaging shared object
sharedObjectID = addClientSharedObject(0, IDFactory.getDefault().createStringID("foo0"), new TestMessagingSharedObject(TEST_USERNAME0, new IMessageReceiver() {
public void handleMessage(ID fromID, Object message) {
System.out.println("received fromId=" + fromID + " message=" + message);
}
}), null);
sharedObject = (TestMessagingSharedObject) getClientSOManager(0).getSharedObject(sharedObjectID);
sleep(2000);
}
Aggregations