1 11 package org.eclipse.core.internal.compatibility; 12 13 import org.eclipse.core.internal.plugins.PluginDescriptor; 14 import org.eclipse.core.runtime.Platform; 15 import org.eclipse.core.runtime.Plugin; 16 import org.osgi.framework.BundleActivator; 17 import org.osgi.framework.BundleContext; 18 19 public class PluginActivator implements BundleActivator { 20 private Plugin plugin; 21 22 public PluginActivator() { 23 super(); 24 } 25 26 public void start(BundleContext context) throws Exception { 27 PluginDescriptor pd = (PluginDescriptor) Platform.getPluginRegistry().getPluginDescriptor(context.getBundle().getSymbolicName()); 28 plugin = pd.getPlugin(); 29 try { 30 plugin.start(context); 31 plugin.startup(); 32 } catch(Exception e) { 33 try { 34 plugin.shutdown(); 35 plugin.stop(context); 36 pd.markAsDeactivated(); 37 } catch(Exception e1) { 38 e1.printStackTrace(); 40 } 41 throw e; 42 } 43 } 44 45 public void stop(BundleContext context) throws Exception { 46 plugin.shutdown(); 47 plugin.stop(context); 48 ((PluginDescriptor) plugin.getDescriptor()).doPluginDeactivation(); 49 } 50 } 51 | Popular Tags |