1 11 package org.eclipse.core.runtime; 12 13 import org.eclipse.core.internal.registry.osgi.OSGIUtils; 14 import org.eclipse.core.runtime.spi.RegistryContributor; 15 import org.osgi.framework.Bundle; 16 17 31 public final class ContributorFactoryOSGi { 32 33 40 public static IContributor createContributor(Bundle contributor) { 41 String id = Long.toString(contributor.getBundleId()); 42 String name = contributor.getSymbolicName(); 43 String hostId = null; 44 String hostName = null; 45 46 if (OSGIUtils.getDefault().isFragment(contributor)) { 48 Bundle[] hosts = OSGIUtils.getDefault().getHosts(contributor); 49 if (hosts != null) { 50 Bundle hostBundle = hosts[0]; 51 hostId = Long.toString(hostBundle.getBundleId()); 52 hostName = hostBundle.getSymbolicName(); 53 } 54 } 55 56 return new RegistryContributor(id, name, hostId, hostName); 57 } 58 59 71 public static Bundle resolve(IContributor contributor) { 72 if (contributor == null) 73 return null; 74 if (!(contributor instanceof RegistryContributor)) 75 return null; 76 String symbolicName = ((RegistryContributor) contributor).getActualName(); 77 return OSGIUtils.getDefault().getBundle(symbolicName); 78 } 79 } 80 | Popular Tags |