1 11 package org.eclipse.core.internal.plugins; 12 13 import java.net.URL ; 14 import org.eclipse.core.internal.model.RegistryLoader; 15 import org.eclipse.core.runtime.*; 16 import org.eclipse.core.runtime.model.Factory; 17 import org.eclipse.core.runtime.model.PluginRegistryModel; 18 import org.osgi.framework.BundleContext; 19 import org.osgi.framework.BundleException; 20 21 22 25 public class InternalPlatform { 26 private static IPluginRegistry registry = null; 27 28 public static IPluginRegistry getPluginRegistry() { 29 if (registry == null) { 30 registry = new PluginRegistry(); 31 } 32 return registry; 33 } 34 35 public static IPluginDescriptor getPluginDescriptor(String pluginId) { 36 return getPluginRegistry().getPluginDescriptor(pluginId); 37 } 38 39 public static void installPlugins(URL [] installURLs) throws CoreException { 40 String message = Policy.bind("platform.errorInstalling"); MultiStatus result = new MultiStatus(Platform.PI_RUNTIME, 0, message, null); 42 BundleContext context = org.eclipse.core.internal.runtime.InternalPlatform.getDefault().getBundleContext(); 43 for (int i = 0; i < installURLs.length; i++) { 44 try { 45 context.installBundle(installURLs[i].toExternalForm()); 46 } catch (BundleException e) { 47 IStatus status = new Status(IStatus.ERROR, Platform.PI_RUNTIME, 0, org.eclipse.core.internal.plugins.Policy.bind("platform.cannotInstallPlugin", installURLs[i].toExternalForm()), e); result.merge(status); 49 } 50 } 51 if (!result.isOK()) 52 throw new CoreException(result); 53 } 54 55 56 60 public static PluginRegistryModel parsePlugins(URL [] pluginPath, Factory factory) { 61 return parsePlugins(pluginPath, factory, false); 62 } 63 64 85 public synchronized static PluginRegistryModel parsePlugins(URL [] pluginPath, Factory factory, boolean debug) { 86 return RegistryLoader.parseRegistry(pluginPath, factory, debug); 87 } 88 89 } 90 | Popular Tags |