programmatically downgrade eclipse plugin

I want to change a plugin in RCP product, but to keep the old plugin alive.

A user can choose between plugin A or B using a configuration.

I thought about creating a new version for the plugin and switch between them according to a flag. The new version will be the default one.

The question is how can I 'downgrade' the plugin in order to get back to the old one if requested?

Comments

It sounds like you need to use OSGI in order to start the correct plugin/bundle (and its dependants).
Basically, u r right - u need another plugin( a "Starter") which decides which version is correct (based on config file or whatever).
but the main func-ty is:

  1. get  a BundleContext  ref (u receive it as an arg in BundleActivator#start() method - in your Starter/Manager plugin's Activator or use: FrameworkUtil.getBundle(this.getClass()).getBundleContext();

  2. BundleContext#getBundles() - get the list of all installed bundles 
  3. iterate through all bundles and pick the one you want(your biz logic) - Bundle#getSymbolicName() and/or Bundle#getVersion()
  4. if (bundle.getState != Bundle.ACTIVE) bundle.start();
  5. u might need to ensure that all dependants are started too (in the same way)
  6. if the plugin was already started(the previous version or whatever) - u need to stop it and its dependants and only then start the new one

some links:

http://www.osgi.org/javadoc/r4v42/org/osgi/framework/BundleContext.html
http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html
http://eclipse.org/equinox/documents/quickstart.php
http://www.vogella.de/articles/OSGi/article.html

hope it helps