1 11 package org.eclipse.core.internal.registry; 12 13 import java.lang.reflect.Method ; 14 import org.eclipse.core.runtime.IPluginDescriptor; 15 import org.osgi.framework.Bundle; 16 17 24 public class RegistryCompatibilityHelper { 25 public static final String PI_RUNTIME_COMPATIBILITY = "org.eclipse.core.runtime.compatibility"; private static Bundle compatibility = null; 27 28 public synchronized static Bundle initializeCompatibility() { 29 if (compatibility == null || (compatibility.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED | Bundle.STOPPING)) != 0) { 32 compatibility = BundleHelper.getDefault().getBundle(PI_RUNTIME_COMPATIBILITY); 33 } 34 return compatibility; 35 } 36 37 public synchronized static IPluginDescriptor getPluginDescriptor(String pluginId) { 38 initializeCompatibility(); 40 if (compatibility == null) 41 throw new IllegalStateException (); 42 43 Class oldInternalPlatform = null; 44 try { 45 oldInternalPlatform = compatibility.loadClass("org.eclipse.core.internal.plugins.InternalPlatform"); Method getPluginDescriptor = oldInternalPlatform.getMethod("getPluginDescriptor", new Class [] {String .class}); return (IPluginDescriptor) getPluginDescriptor.invoke(oldInternalPlatform, new Object [] {pluginId}); 48 } catch (Exception e) { 49 } 51 return null; 52 } 53 } 54 | Popular Tags |