1 12 package org.eclipse.pde.internal.build; 13 14 import java.util.*; 15 import org.eclipse.core.runtime.*; 16 import org.eclipse.pde.build.IFetchFactory; 17 18 22 public class FetchTaskFactoriesRegistry implements IPDEBuildConstants { 23 24 private Map factories; 26 27 public FetchTaskFactoriesRegistry() { 28 factories = new HashMap(); 29 initializeRegistry(); 30 } 31 32 42 public IFetchFactory getFactory(String id) { 43 Object result = factories.get(id); 44 if (result instanceof IFetchFactory) 45 return (IFetchFactory) result; 46 47 IConfigurationElement extension = (IConfigurationElement) factories.get(id); 48 if (null != extension) { 49 try { 50 IFetchFactory toCache = (IFetchFactory) extension.createExecutableExtension(ATTR_CLASS); 51 factories.put(id, toCache); 52 return toCache; 53 } catch (CoreException e) { 54 BundleHelper.getDefault().getLog().log(e.getStatus()); 55 } 56 } 57 return null; 58 } 59 60 65 public Collection getFactoryIds() { 66 return factories.keySet(); 67 } 68 69 72 private void initializeRegistry() { 73 IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(EXT_FETCH_TASK_FACTORIES); 74 for (int i = 0; i < extensions.length; i++) { 75 IConfigurationElement extension = extensions[i]; 76 if (ELEM_FACTORY.equals(extension.getName())) { 77 String id = extension.getAttribute(ATTR_ID); 78 if (null != id && id.trim().length() > 0) { 79 factories.put(id, extension); 80 } 81 } 82 } 83 } 84 } 85 | Popular Tags |