|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IModelSynchronizationStrategy
Model synchronization strategy contract. Model synchronization strategy instances are used to synchronize replicated instances of an arbitrary model. This is done by creating instances implementing this interface on participating processes, and then using them in the following manner.
First, assume for simplicity that there are two processes (A and B), each with a replica of a given model (a and b). Also assume that prior to using a synchronization strategy that the model is accurately and reliably replicated to A and B (i.e. a == b). Further, assume that for both A and B an instance of IModelSynchronizationStrategy is created (call them Sa and Sb) prior to any changes being made to either a or b.
On process A assume that the user makes a change to a via a (local) editor. Then the expected sequence of activities is as follows:
registerLocalChange(IModelChange)
. The IModelChange instance
provided must be 1) not null
; and 2) Of a type that is
appropriate for this synchronization strategy.IModelChangeMessage
,
serialize it (by calling IModelChangeMessage.serialize()
and send the
message to remote processes (i.e. B).deserializeRemoteChange(byte[])
to create an IModelChange instance.transformRemoteChange(IModelChange)
. The synchronization
implementation will then return an array of IModelChange instances
(IModelChange []). These IModelChange instance should then be cast to the
appropriate type, and applied to the local instance of the model (i.e. b).
The transformRemoteChange(IModelChange)
metho will take the local
changes (previously registered with the synchronization strategy via
registerLocalChange(IModelChange)
), and the remote changes provided
via transformRemoteChange(IModelChange)
, and transform the changes
into a set that will result in a synchronized local copy.
Note that clients should generally call the
registerLocalChange(IModelChange)
and apply the IModelChanges
returned from transformRemoteChange(IModelChange)
on the same thread
that is responsible for modifying the underlying model. For example, if a
document model is modified by an editor (via UI thread) then the UI thread
should also synchronously call registerLocalChange(IModelChange)
,
and the changes from transformRemoteChange(IModelChange)
should also
be applied to the local document from within this same thread.
Method Summary | |
---|---|
IModelChange |
deserializeRemoteChange(byte[] bytes)
Deserialization of given byte array to concrete instance of IModelChange object to represent local change to be applied |
IModelChangeMessage[] |
registerLocalChange(IModelChange localChange)
Register local model change with synchronization strategy. |
IModelChange[] |
transformRemoteChange(IModelChange remoteChange)
Transform remote change into a set of local changes to be synchronously applied to the local model. |
Methods inherited from interface org.eclipse.core.runtime.IAdaptable |
---|
getAdapter |
Method Detail |
---|
IModelChangeMessage[] registerLocalChange(IModelChange localChange)
localChange
- the IModelChange made to the local model. Must be non-
null
, and must be of type appropriate for the
synchronization strategy.
IModelChange[] transformRemoteChange(IModelChange remoteChange)
remoteChange
- the remote model change instance to be transformed by this
synchronization strategy.
IModelChange deserializeRemoteChange(byte[] bytes) throws SerializationException
bytes
- the bytes to be deserialized.
null
.
SerializationException
- thrown if some problem deserializing given bytes.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |