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());
	}
}

 

Copyright IBM Corporation and others 2000, 2003.