/** * Finds all implementations of DataStoreFactory which have registered using the services * mechanism, and that have the appropriate libraries on the classpath. * * @return An iterator over all discovered DataStores which have registered factories, and whose * available method returns true. */ public static synchronized Iterator<DataSourceFactorySpi> getAvailableDataSources() { Stream<DataSourceFactorySpi> factories = getServiceRegistry().getFactories(DataSourceFactorySpi.class, null, null); // results are collected into HashSet (even though iterator is returned) // to find broken implementations early rather than later caller code Set<DataSourceFactorySpi> availableDS = factories .filter(dsFactory -> dsFactory.isAvailable()) .collect(Collectors.toCollection(HashSet::new)); return availableDS.iterator(); }
/** * Finds all implemtaions of DataStoreFactory which have registered using the services * mechanism, and that have the appropriate libraries on the classpath. * * @return An iterator over all discovered datastores which have registered factories, and whose * available method returns true. */ public static synchronized Iterator getAvailableDataSources() { Set availableDS = new HashSet(); Iterator it = getServiceRegistry().getServiceProviders(DataSourceFactorySpi.class, null, null); DataSourceFactorySpi dsFactory; while (it.hasNext()) { dsFactory = (DataSourceFactorySpi) it.next(); if (dsFactory.isAvailable()) { availableDS.add(dsFactory); } } return availableDS.iterator(); }
/** * Finds all implemtaions of DataStoreFactory which have registered using the services * mechanism, and that have the appropriate libraries on the classpath. * * @return An iterator over all discovered datastores which have registered factories, and whose * available method returns true. */ public static synchronized Iterator getAvailableDataSources() { Set availableDS = new HashSet(); Iterator it = getServiceRegistry().getServiceProviders(DataSourceFactorySpi.class); DataSourceFactorySpi dsFactory; while (it.hasNext()) { dsFactory = (DataSourceFactorySpi) it.next(); if (dsFactory.isAvailable()) { availableDS.add(dsFactory); } } return availableDS.iterator(); }