public class ThreadedModelResolver extends AbstractModelResolver implements IGraphConsumer
IModelResolver
will look up all of the models located in a set container
level of the "starting point" (by default, the containing project) to construct the graph of dependencies
between these models.
Once this graph is created for the "local" resource, the right and origin (if any) resources will be inferred from the same traversal of resources, though this time expanded with a "top-down" approach : load all models of the traversal from the remote side, then resolve their containment tree to check whether there are other remote resources in the logical model that do not (or "that no longer) exist locally and thus couldn't be discovered in the first resolution phase. Note that this will be looped in order to determine whether the resource is really inexistent locally, or if on the contrary, it is a new dependency that's been added remotely; in which case we need to start from the local resolution again : the local resource may have changed locally and depend on other again.
All model loading will happen concurrently. At first, a distinct thread will be launched to resolve every model discovered in the container we're browsing. Then, each thread can and will launch separate threads to resolve the set of dependencies discovered "under" the model they are in charge of resolving.
No model will be loaded twice, since this will be aware of what models have already been resolved, thus ignoring duplicate resolving demands.
Constructor and Description |
---|
ThreadedModelResolver() |
Modifier and Type | Method and Description |
---|---|
boolean |
canResolve(org.eclipse.core.resources.IStorage sourceStorage)
This will be used in order to determine whether this resolver can be used for the given storage.
|
protected DefaultResolutionContext |
createContext(com.google.common.eventbus.EventBus eventBus,
IGraph<URI> aGraph)
For testing purposes, this method is protected.
|
void |
dispose()
This will be called when the contributing plugin of this class is about to be stopped.
|
IGraphView<URI> |
getGraphView()
Convert the dependency graph to its read-only version.
|
String |
getId()
Getter for the ID of the Resource Graph.
|
void |
initialize()
This will be called as soon as the class is created by the registry.
|
StorageTraversal |
resolveLocalModel(org.eclipse.core.resources.IResource start,
org.eclipse.core.runtime.IProgressMonitor monitor)
This will be called by Team in order to determine whether a given file can be compared alone, or if it
needs to be compared along with others (and, thus, compared from the synchronize view).
|
SynchronizationModel |
resolveLocalModels(org.eclipse.core.resources.IResource left,
org.eclipse.core.resources.IResource right,
org.eclipse.core.resources.IResource origin,
org.eclipse.core.runtime.IProgressMonitor monitor)
Called by EMF Compare in order to resolve the logical models corresponding to the given IResources.
|
SynchronizationModel |
resolveModels(IStorageProviderAccessor storageAccessor,
org.eclipse.core.resources.IStorage left,
org.eclipse.core.resources.IStorage right,
org.eclipse.core.resources.IStorage origin,
org.eclipse.core.runtime.IProgressMonitor monitor)
This will be called by EMF Compare in order to resolve the whole logical models containing the given
storages.
|
void |
setGraph(IGraph<URI> graph)
Setter for the URI Graph istance.
|
public IGraphView<URI> getGraphView()
getGraphView
in interface IGraphConsumer
public void initialize()
#graphUpdater
to its #eventBus
#scheduler
initialize
in interface IModelResolver
initialize
in class AbstractModelResolver
IModelResolver.initialize()
public void dispose()
dispose
in interface IModelResolver
dispose
in class AbstractModelResolver
IModelResolver.dispose()
protected DefaultResolutionContext createContext(com.google.common.eventbus.EventBus eventBus, IGraph<URI> aGraph)
eventBus
- aGraph
- public boolean canResolve(org.eclipse.core.resources.IStorage sourceStorage)
canResolve
in interface IModelResolver
sourceStorage
- The resource we're trying to resolve the logical model of. This will always be the "source"
or "left" variant of the compared resource.true
if this resolver is capable of handling the given storage, false
otherwise.public StorageTraversal resolveLocalModel(org.eclipse.core.resources.IResource start, org.eclipse.core.runtime.IProgressMonitor monitor) throws InterruptedException
Note that no two threads will be able to resolve models at once : all three "resolve*" methods will lock internally to prevent multiple resolutions at once. Though this shouldn't happen unless the user calls multiple comparisons one after the other in quick succession, we use this locking to prevent potential unforeseen interactions.
resolveLocalModel
in interface IModelResolver
start
- The workspace resource for which we need a traversal.monitor
- Monitor on which to report progress to the user.InterruptedException
- Thrown if the resolution is cancelled or interrupted one way or another.public SynchronizationModel resolveLocalModels(org.eclipse.core.resources.IResource left, org.eclipse.core.resources.IResource right, org.eclipse.core.resources.IResource origin, org.eclipse.core.runtime.IProgressMonitor monitor) throws InterruptedException
Note that no two threads will be able to resolve models at once : all three "resolve*" methods will lock internally to prevent multiple resolutions at once. Though this shouldn't happen unless the user calls multiple comparisons one after the other in quick succession, we use this locking to prevent potential unforeseen interactions.
resolveLocalModels
in interface IModelResolver
left
- The file that will be considered as the "starting point" of the traversal to resolve as the
left logical model.right
- "starting point" of the traversal to resolve as the right logical model.origin
- "starting point" of the traversal to resolve as the origin logical model (common ancestor of
left and right). Can be null
.monitor
- Monitor on which to report progress to the user.InterruptedException
- Thrown if the resolution is cancelled or interrupted one way or another.public SynchronizationModel resolveModels(IStorageProviderAccessor storageAccessor, org.eclipse.core.resources.IStorage left, org.eclipse.core.resources.IStorage right, org.eclipse.core.resources.IStorage origin, org.eclipse.core.runtime.IProgressMonitor monitor) throws InterruptedException
Note that no two threads will be able to resolve models at once : all three "resolve*" methods will lock internally to prevent multiple resolutions at once. Though this shouldn't happen unless the user calls multiple comparisons one after the other in quick succession, we use this locking to prevent potential unforeseen interactions.
resolveModels
in interface IModelResolver
storageAccessor
- The accessor that can be used to retrieve synchronization information between our resources.left
- The storage that will be considered as the "starting point" of the traversal to resolve as
the left logical model.right
- "starting point" of the traversal to resolve as the right logical model.origin
- "starting point" of the traversal to resolve as the origin logical model (common ancestor of
left and right). Can be null
.monitor
- Monitor on which to report progress to the user.InterruptedException
- Thrown if the resolution is cancelled or interrupted one way or another.public String getId()
getId
in interface IGraphConsumer
public void setGraph(IGraph<URI> graph)
setGraph
in interface IGraphConsumer
graph
- The URI Graph
Copyright (c) 2006, 2015 Obeo and others. All rights reserved.