Search in sources :

Example 6 with SerializationException

use of org.eclipse.ecf.sync.SerializationException in project ecf by eclipse.

the class Message method serialize.

public byte[] serialize() throws SerializationException {
    try {
        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(this);
        return bos.toByteArray();
    } catch (final Exception e) {
        throw new SerializationException(Messages.DocShare_EXCEPTION_DESERIALIZING_MESSAGE0, e);
    }
}
Also used : SerializationException(org.eclipse.ecf.sync.SerializationException) SerializationException(org.eclipse.ecf.sync.SerializationException)

Example 7 with SerializationException

use of org.eclipse.ecf.sync.SerializationException in project ecf by eclipse.

the class Message method deserialize.

/**
 * Deserialize in to message
 * @param bytes
 * @return IModelChangeMessage
 * @throws SerializationException
 */
public static IModelChangeMessage deserialize(byte[] bytes) throws SerializationException {
    try {
        final ByteArrayInputStream bins = new ByteArrayInputStream(bytes);
        final ObjectInputStream oins = new ObjectInputStream(bins);
        return (IModelChangeMessage) oins.readObject();
    } catch (final Exception e) {
        throw new SerializationException(Messages.DocShare_EXCEPTION_DESERIALIZING_MESSAGE0, e);
    }
}
Also used : SerializationException(org.eclipse.ecf.sync.SerializationException) IModelChangeMessage(org.eclipse.ecf.sync.IModelChangeMessage) SerializationException(org.eclipse.ecf.sync.SerializationException)

Example 8 with SerializationException

use of org.eclipse.ecf.sync.SerializationException in project ecf by eclipse.

the class SharedDocClient method processRemoteMessage.

private void processRemoteMessage(byte[] msg) {
    if (msg != null) {
        try {
            synchronized (this.getClass()) {
                IModelChange change = syncStrategy.deserializeRemoteChange(msg);
                System.out.println(name + ";received=" + change);
                IDocumentChange[] documentChanges = (IDocumentChange[]) syncStrategy.transformRemoteChange(change);
                for (int i = 0; i < documentChanges.length; i++) {
                    applyChangeToLocalDocument(false, documentChanges[i]);
                }
            }
        } catch (SerializationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
Also used : SerializationException(org.eclipse.ecf.sync.SerializationException) IModelChange(org.eclipse.ecf.sync.IModelChange) IDocumentChange(org.eclipse.ecf.sync.doc.IDocumentChange)

Example 9 with SerializationException

use of org.eclipse.ecf.sync.SerializationException in project ecf by eclipse.

the class Message method serialize.

static byte[] serialize(Object object) throws SerializationException {
    try {
        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(object);
        return bos.toByteArray();
    } catch (IOException e) {
        throw new SerializationException(e);
    }
}
Also used : SerializationException(org.eclipse.ecf.sync.SerializationException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream)

Aggregations

SerializationException (org.eclipse.ecf.sync.SerializationException)9 IModelChangeMessage (org.eclipse.ecf.sync.IModelChangeMessage)3 IOException (java.io.IOException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 IModelChange (org.eclipse.ecf.sync.IModelChange)1 ModelUpdateException (org.eclipse.ecf.sync.ModelUpdateException)1 IDocumentChange (org.eclipse.ecf.sync.doc.IDocumentChange)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1