private BrailleTranslatorFactoryMaker() { logger = Logger.getLogger(BrailleTranslatorFactoryMaker.class.getCanonicalName()); factories = new ArrayList<BrailleTranslatorFactory>(); Iterator<BrailleTranslatorFactory> i = ServiceRegistry.lookupProviders(BrailleTranslatorFactory.class); while (i.hasNext()) { factories.add(i.next()); } this.map = new HashMap<String, BrailleTranslatorFactory>(); }
@Override public boolean hasNext() { while ((spiIT == null || !spiIT.hasNext()) && (loaderIt.hasNext())) { final ClassLoader l = loaderIt.next(); if (checkset.contains(l)) continue; checkset.add(l); spiIT = (Iterator<T>) ServiceRegistry.lookupProviders(service, l); } return spiIT != null && spiIT.hasNext(); }
public static <T> T loadService(Class<T> providerClass) { Iterator i = ServiceRegistry.lookupProviders(providerClass); if(!i.hasNext()) throw new IllegalStateException("No service found for " + providerClass); T service = providerClass.cast(i.next()); if(i.hasNext()) throw new IllegalStateException("More than 1 service found for " + providerClass); return service; } }
public static synchronized <T extends Object> Iterator<T> lookupProviderWithOrientClassLoader(Class<T> clazz,ClassLoader orientClassLoader) { ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(orientClassLoader); Iterator<T> lookupProviders = ServiceRegistry.lookupProviders(clazz); Thread.currentThread().setContextClassLoader(origClassLoader); return lookupProviders; }
protected HyphenatorFactoryMaker() { logger = Logger.getLogger(HyphenatorFactoryMaker.class.getCanonicalName()); filters = new ArrayList<HyphenatorFactory>(); Iterator<HyphenatorFactory> i = ServiceRegistry.lookupProviders(HyphenatorFactory.class); while (i.hasNext()) { filters.add(i.next()); } this.map = new HashMap<FilterLocale, HyphenatorFactory>(); beginLimit = null; endLimit = null; }
protected UncontractedBrailleFilterFactory() { logger = Logger.getLogger(UncontractedBrailleFilterFactory.class.getCanonicalName()); filters = new ArrayList<UncontractedBrailleFilter>(); Iterator<UncontractedBrailleFilter> i = ServiceRegistry.lookupProviders(UncontractedBrailleFilter.class); UncontractedBrailleFilter f; while (i.hasNext()) { f = i.next(); filters.add(f); } this.cache = new HashMap<FilterLocale, UncontractedBrailleFilter>(); }
/** * Creates a new hyphenator factory maker. * @return returns a new hyphenator factory maker */ public static HyphenatorFactoryMaker newInstance() { Iterator<HyphenatorFactoryMaker> i = ServiceRegistry.lookupProviders(HyphenatorFactoryMaker.class); while (i.hasNext()) { return i.next(); } return new HyphenatorFactoryMaker(); }
/** * Gets a new instance of BrailleFilterFactory * @return returns a new instance of BrailleFilterFactory */ public static UncontractedBrailleFilterFactory newInstance() { Iterator<UncontractedBrailleFilterFactory> i = ServiceRegistry.lookupProviders(UncontractedBrailleFilterFactory.class); while (i.hasNext()) { return i.next(); } return new UncontractedBrailleFilterFactory(); }
public static BrailleTranslatorFactoryMaker newInstance() { Iterator<BrailleTranslatorFactoryMaker> i = ServiceRegistry.lookupProviders(BrailleTranslatorFactoryMaker.class); while (i.hasNext()) { return i.next(); } return new BrailleTranslatorFactoryMaker(); }
protected DefaultPaperCatalog() { map = new HashMap<String, Paper>(); Iterator<PaperProvider> i = ServiceRegistry.lookupProviders(PaperProvider.class); while (i.hasNext()) { PaperProvider provider = i.next(); for (Paper paper : provider.list()) { map.put(paper.getIdentifier(), paper); } } }
/** * Obtains a new instance of a Validator with the given identifier * @param identifier a string that identifies the desired implementation * @return returns a Validator for the given identifier, or null if none is found */ public Validator newValidator(String identifier) { Iterator<Validator> i = ServiceRegistry.lookupProviders(Validator.class); while (i.hasNext()) { Validator v = i.next(); if (identifier.equals(v.getIdentifier())) { return v; } } return null; }
/** * Obtains a new EmbosserCatalog instance. If at least one implementation can be found * using the Services API, then the first one will be returned. Otherwise the default EmbosserCatalog * will be used. * * The default EmbosserCatalog will use the Services API to * find EmbosserProviders. The combined result from all EmbosserProviders are available to * the catalog. * @return returns a new EmbosserCatalog instance. */ public static EmbosserCatalog newInstance() { Iterator<EmbosserCatalog> i = ServiceRegistry.lookupProviders(EmbosserCatalog.class); while (i.hasNext()) { return i.next(); } return new DefaultEmbosserCatalog(); } }
protected DefaultTableCatalog() { map = new HashMap<String, Table>(); Iterator<TableProvider> i = ServiceRegistry.lookupProviders(TableProvider.class); while (i.hasNext()) { TableProvider provider = i.next(); for (Table table : provider.list()) { map.put(table.getIdentifier(), table); } } }
/** * Obtains a new TableCatalog instance. If at least one implementation can be found * using the Services API, then the first one will be returned. Otherwise the default TableCatalog * will be used. * * The default TableCatalog will use the Services API to * find TableProviders. The combined result from all TableProviders are available to * the catalog. * @return returns a new TableCatalog instance. */ public static TableCatalog newInstance() { Iterator<TableCatalog> i = ServiceRegistry.lookupProviders(TableCatalog.class); while (i.hasNext()) { return i.next(); } return new DefaultTableCatalog(); }
protected DefaultEmbosserCatalog() { map = new HashMap<String, Embosser>(); Iterator<EmbosserProvider> i = ServiceRegistry.lookupProviders(EmbosserProvider.class); while (i.hasNext()) { EmbosserProvider provider = i.next(); for (Embosser embosser : provider.list()) { map.put(embosser.getIdentifier(), embosser); } } }
private RdbmsConnectionFactory newFactory(DatabaseMetaData metaData) throws SQLException { String dbn = metaData.getDatabaseProductName(); String dbv = metaData.getDatabaseProductVersion(); RdbmsConnectionFactory factory; Iterator<RdbmsProvider> providers; providers = ServiceRegistry.lookupProviders(RdbmsProvider.class); while (providers.hasNext()) { RdbmsProvider provider = providers.next(); factory = provider.createRdbmsConnectionFactory(dbn, dbv); if (factory != null) return factory; } return new RdbmsConnectionFactory(); }
protected void initializeIfNeeded() { if (!initialized) { onStartInitialization(); //getClass().getClassLoader() to work under OSGi context Iterator<Discovery> discoveries = ServiceRegistry.lookupProviders(registryType, getClass().getClassLoader()); if(LOGGER.isLoggable(Level.FINE)){ LOGGER.fine("discoveries found ? "+ discoveries.hasNext()); } while (discoveries.hasNext()) { Discovery instance = discoveries.next(); boolean result = registerInstance(instance); if(LOGGER.isLoggable(Level.FINE)){ LOGGER.fine("Registered Discovery instance "+ instance+ " "+ result); } } onEndInitialization(); } }
public DefaultAppBloodhound() { // defaults first parserRegistry.put("properties", new PropertiesDescriptorParser()); final Iterator<DescriptorParser> it = ServiceRegistry.lookupProviders(DescriptorParser.class); MultiMap overrides = new MultiValueMap(); while (it.hasNext()) { final DescriptorParser parser = it.next(); overrides.put(parser.getSupportedFormat(), parser); } mergeParserOverrides(overrides); }
/** Set up the JPEG-2000 image reader. */ private J2KImageReader getReader() { final IIORegistry registry = IIORegistry.getDefaultInstance(); final Iterator<J2KImageReaderSpi> iter = ServiceRegistry.lookupProviders(J2KImageReaderSpi.class); registry.registerServiceProviders(iter); final J2KImageReaderSpi spi = registry.getServiceProviderByClass(J2KImageReaderSpi.class); return new J2KImageReader(spi); }
/** Set up the JPEG-2000 image reader. */ private J2KImageReader getReader() { final IIORegistry registry = IIORegistry.getDefaultInstance(); final Iterator<J2KImageReaderSpi> iter = ServiceRegistry.lookupProviders(J2KImageReaderSpi.class); registry.registerServiceProviders(iter); final J2KImageReaderSpi spi = registry.getServiceProviderByClass(J2KImageReaderSpi.class); return new J2KImageReader(spi); }