1 19 package org.netbeans.modules.xml.catalog.spi; 20 21 import java.util.*; 22 import java.io.IOException ; 23 24 import org.openide.util.Lookup; 25 26 35 public final class ProvidersRegistry { 36 37 42 public static final synchronized Iterator getProviderClasses(Class [] filter) { 43 44 Lookup.Template template = new Lookup.Template(CatalogProvider.class); 45 Lookup.Result res = Lookup.getDefault().lookup(template); 46 Iterator it = res.allInstances().iterator(); 47 Set set = new LinkedHashSet(); 48 49 while(it.hasNext()) { 50 try { 51 CatalogProvider next = (CatalogProvider) it.next(); 52 set.add(next.provideClass()); 53 } catch (ClassNotFoundException ex) { 54 } catch (IOException ex) { 56 } 58 } 59 60 it = set.iterator(); 61 62 if (filter == null) 63 return it; 64 65 ArrayList list = new ArrayList(); 66 67 try_next_provider_class: 68 while (it.hasNext()) { 69 Class next = (Class ) it.next(); 70 71 73 for (int i=0; i<filter.length; i++) { 74 75 if (filter[i].isAssignableFrom(next) == false) 76 continue try_next_provider_class; 77 } 78 79 81 list.add(next); 82 } 83 84 return list.iterator(); 85 } 86 87 } 88 | Popular Tags |