1 19 20 package org.netbeans.modules.xml.wsdl.validator; 21 22 import java.util.Collection ; 23 import java.util.Hashtable ; 24 25 import org.netbeans.modules.xml.wsdl.validator.spi.ValidatorSchemaFactory; 26 import org.openide.util.Lookup; 27 28 public class ValidatorSchemaFactoryRegistry { 29 30 private static ValidatorSchemaFactoryRegistry registry; 31 private Hashtable <String , ValidatorSchemaFactory> schemaFactories; 32 33 private ValidatorSchemaFactoryRegistry() { 34 initialize(); 35 } 36 37 public static ValidatorSchemaFactoryRegistry getDefault() { 38 if (registry == null) { 39 registry = new ValidatorSchemaFactoryRegistry(); 40 } 41 return registry; 42 } 43 44 private void initialize() { 45 schemaFactories = new Hashtable <String , ValidatorSchemaFactory>(); 46 Lookup.Result results = Lookup.getDefault().lookup(new Lookup.Template(ValidatorSchemaFactory.class)); 47 for (Object service : results.allInstances()){ 48 ValidatorSchemaFactory factory = (ValidatorSchemaFactory) service; 49 schemaFactories.put(factory.getNamespaceURI(), factory); 50 } 51 } 52 53 public ValidatorSchemaFactory getValidatorSchemaFactory(String namespace) { 54 return schemaFactories.get(namespace); 55 } 56 57 public Collection <ValidatorSchemaFactory> getAllValidatorSchemaFactories() { 58 return schemaFactories.values(); 59 } 60 61 } 62 | Popular Tags |