Implementing a repository provider

The org.eclipse.team.core.repository extension point is used to add a repository definition.  Here is the markup for the CVS client.

<extension
    point="org.eclipse.team.core.repository">
      <repository
            class="org.eclipse.team.internal.ccvs.core.CVSTeamProvider"
            id="org.eclipse.team.cvs.core.cvsprovider">
      </repository>
</extension>

This registers your team provider with the team support plug-in and assigns an id that should be used when your provider is associated with a project.  The specified class for the repository must extend RepositoryProvider.

Implementing a provider

The class identified in the extension must be a subclass of RepositoryProvider. Its primary responsibilities are to configure and deconfigure a project for repository support, and supply any necessary resource modification hooks.  The CVS client serves as a good example.  Its repository provider is CVSTeamProvider.

   public class CVSTeamProvider extends RepositoryProvider {

	...
	

RepositoryProvider defines two abstract methods, configureProject and deconfigure.  All providers must implement these methods. 

A project is configured when it is first associated with a particular repository provider.  This typically happens when the user selects a project and uses the team wizards to associate a project with your repository.  Regardless of how the operation is triggered, this is the appropriate time to compute or cache any data about the project that you'll need to provide your repository function.  (Assume that mapping the project to your provider has already happened.  You'll be taking care of this in your configuration wizard.)

The CVS provider simply broadcasts the fact that a project has been configured:

public void configureProject() throws CoreException {
	CVSProviderPlugin.broadcastProjectConfigured(getProject());
}

We won't follow the implementation of the plug-in broadcast mechanism.  Suffice to say that any parties that need to compute or initialize project specific data can do so at this time.

A project is deconfigured when the user no longer wants to associate a team provider with a project.   It is up to your plug-in to implement the user action that causes this to happen (and unmapping the project from your team provider will happen there).  The deconfigure method  is the appropriate time to delete any project related caches or remove any references to the project in the UI.  The CVS provider flushes project related caches kept in its views and broadcasts the fact that the project is deconfigured.

public void deconfigure() throws CoreException {
	...
	try {
		EclipseSynchronizer.getInstance().flush(getProject(), true, true /*flush deep*/, null);
	} catch(CVSException e) {
		throw new CoreException(e.getStatus());
	} finally {
		CVSProviderPlugin.broadcastProjectDeconfigured(getProject());
	}
}

Resource modification hooks

Most of the interesting function associated with a repository provider occurs as the user works with resources in the project that is configured for the provider.  In order to be aware of changes the user makes to a resource, the provider can implement resource modification hooks.  The resources plug-in provides these hooks as extension points.  The documentation for IMoveDeleteHook and IFileModificationValidator describe the details for implementing these hooks.

The team plug-in optimizes and simplifies the association of the hook with appropriate resources by registering generic hooks with the resources plug-in.  These generic hooks simply look up the repository provider for a given resource and obtain its hook.  This has the advantage of calling only one provider hook rather than having each provider implementation register a hook that must first check whether the resource is managed by the provider.

What this means to your plug-in is that you provide any necessary hooks by overriding methods in RepositoryProviderThe default implementation of these methods answers null, indicating that no hook is necessary.

Copyright IBM Corporation and others 2000, 2003.