public class ThreadedModelResolver extends AbstractModelResolver
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()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canResolve(IStorage sourceStorage)
This will be used in order to determine whether this resolver can be used for the given storage.
|
protected void |
demandRemoteResolve(org.eclipse.emf.compare.ide.ui.internal.logical.resolver.SynchronizedResourceSet resourceSet,
URI uri,
ThreadSafeProgressMonitor monitor)
Allows callers to launch the loading and resolution of the model pointed at by the given URI, without
updating the
dependencyGraph along the way. |
protected void |
demandResolve(org.eclipse.emf.compare.ide.ui.internal.logical.resolver.SynchronizedResourceSet resourceSet,
URI uri,
ThreadSafeProgressMonitor monitor)
Allows callers to launch the loading and resolution of the model pointed at by the given URI.
|
protected void |
demandUnload(org.eclipse.emf.compare.ide.ui.internal.logical.resolver.SynchronizedResourceSet resourceSet,
Resource resource,
ThreadSafeProgressMonitor monitor)
Allows callers to launch the unloading of the given resource.
|
void |
dispose()
This will be called when the contributing plugin of this class is about to be stopped.
|
void |
initialize()
This will be called as soon as the class is created by the registry.
|
StorageTraversal |
resolveLocalModel(IResource start,
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(IResource left,
IResource right,
IResource origin,
IProgressMonitor monitor)
Called by EMF Compare in order to resolve the logical models corresponding to the given IResources.
|
SynchronizationModel |
resolveModels(IStorageProviderAccessor storageAccessor,
IStorage left,
IStorage right,
IStorage origin,
IProgressMonitor monitor)
This will be called by EMF Compare in order to resolve the whole logical models containing the given
storages.
|
public void initialize()
initialize
in interface IModelResolver
initialize
in class AbstractModelResolver
IModelResolver.initialize()
public void dispose()
dispose
in interface IModelResolver
dispose
in class AbstractModelResolver
IModelResolver.dispose()
public boolean canResolve(IStorage sourceStorage)
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(IResource start, 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.
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(IResource left, IResource right, IResource origin, 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.
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, IStorage left, IStorage right, IStorage origin, 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.
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.protected void demandResolve(org.eclipse.emf.compare.ide.ui.internal.logical.resolver.SynchronizedResourceSet resourceSet, URI uri, ThreadSafeProgressMonitor monitor)
This will check whether the given storage isn't already being resolved, then submit a job to the
resolvingPool
to load and resolve the model in a separate thread.
resourceSet
- The resource set in which to load the resource.uri
- The uri we are to try and load as a model.monitor
- Monitor on which to report progress to the user.ResourceResolver
protected void demandRemoteResolve(org.eclipse.emf.compare.ide.ui.internal.logical.resolver.SynchronizedResourceSet resourceSet, URI uri, ThreadSafeProgressMonitor monitor)
dependencyGraph
along the way.
This will check whether the given storage isn't already being resolved, then submit a job to the
resolvingPool
to load and resolve the model in a separate thread.
resourceSet
- The resource set in which to load the resource.uri
- The uri we are to try and load as a model.monitor
- Monitor on which to report progress to the user.protected void demandUnload(org.eclipse.emf.compare.ide.ui.internal.logical.resolver.SynchronizedResourceSet resourceSet, Resource resource, ThreadSafeProgressMonitor monitor)
Do note that even though this is called "unload", we won't actually call Resource.unload()
on
the given resource unless we deem it necessary (we only call if for UML because of the CacheAdapter)
for now. This will only remove the resource from its containing resource set so as to allow it to be
garbage collected.
resourceSet
- The resource set containing the resource to be unloaded.resource
- The resource to unload.monitor
- Monitor on which to report progress to the user.ResourceUnloader
Copyright (c) 2006, 2014 Obeo and others. All rights reserved.