/** * Checks each available datasource implementation in turn and returns the first one which * claims to support the resource identified by the params object. * * @param params A Map object which contains a defenition of the resource to connect to. for * file based resources the property 'url' should be set within this Map. * @return The first datasource which claims to process the required resource, returns null if * none can be found. * @throws IOException If a suitable loader can be found, but it can not be attached to the * specified resource without errors. */ public static synchronized DataStore getDataStore(Map params) throws IOException { Iterator<DataStoreFactorySpi> ps = getAvailableDataStores(); DataAccess<? extends FeatureType, ? extends Feature> dataStore; dataStore = DataAccessFinder.getDataStore(params, ps); return (DataStore) dataStore; }
/** * Finds all implemtaions of DataAccessFactory 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<DataAccessFactory> getAvailableDataStores() { FactoryRegistry serviceRegistry = getServiceRegistry(); Set<DataAccessFactory> availableDS = getAvailableDataStores(serviceRegistry, DataAccessFactory.class); Iterator<DataStoreFactorySpi> availableDataStores = DataStoreFinder.getAvailableDataStores(); while (availableDataStores.hasNext()) { availableDS.add(availableDataStores.next()); } return availableDS.iterator(); }
for (Iterator<DataStoreFactorySpi> iter = DataStoreFinder.getAvailableDataStores(); iter.hasNext(); ) { factoryList.add(iter.next());
@SuppressWarnings("unchecked") public void testGetAvailableDataStores() { Iterator<DataStoreFactorySpi> availableDataStores; availableDataStores = DataStoreFinder.getAvailableDataStores(); assertNotNull(availableDataStores); assertTrue(availableDataStores.hasNext()); DataStoreFactorySpi dsf = availableDataStores.next(); assertFalse(availableDataStores.hasNext()); assertTrue(dsf instanceof MockDataStoreFactory); }
/** Populates the list of available data stores that can be connected to. */ private void populateAvailableDataStores() { DataAccessFactory fac = null; logger.debug("Available data store factories:"); Iterator<DataStoreFactorySpi> iterator = DataStoreFinder.getAvailableDataStores(); while (iterator.hasNext()) { fac = iterator.next(); logger.debug("\t" + fac.getDisplayName()); availableDataStoreList.add(fac.getDisplayName()); } }
/** * Checks each available datasource implementation in turn and returns the * first one which claims to support the resource identified by the params * object. * * @param params A Map object which contains a defenition of the resource * to connect to. for file based resources the property 'url' * should be set within this Map. * * @return The first datasource which claims to process the required * resource, returns null if none can be found. * * @throws IOException If a suitable loader can be found, but it can not be * attached to the specified resource without errors. */ public static synchronized DataStore getDataStore(Map params) throws IOException { Iterator<DataStoreFactorySpi> ps = getAvailableDataStores(); DataAccess<? extends FeatureType, ? extends Feature> dataStore; dataStore = DataAccessFinder.getDataStore(params, ps); return (DataStore) dataStore; }
/** Populate name map. */ private static void populateNameMap() { Iterator<DataStoreFactorySpi> datastore = DataStoreFinder.getAvailableDataStores(); while (datastore.hasNext()) { DataStoreFactorySpi dSPI = datastore.next(); Param dbType = null; for (Param param : dSPI.getParametersInfo()) { if (param.key.equals(JDBCDataStoreFactory.DBTYPE.key)) { dbType = param; break; } } if (dbType != null) { nameMap.put(dSPI.getDisplayName(), (String) dbType.sample); } } }
/** * Finds all implemtaions of DataAccessFactory 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<DataAccessFactory> getAvailableDataStores() { FactoryRegistry serviceRegistry = getServiceRegistry(); Set<DataAccessFactory> availableDS = getAvailableDataStores(serviceRegistry, DataAccessFactory.class); Iterator<DataStoreFactorySpi> availableDataStores = DataStoreFinder .getAvailableDataStores(); while (availableDataStores.hasNext()) { availableDS.add(availableDataStores.next()); } return availableDS.iterator(); }
for( Iterator<DataStoreFactorySpi> iter = DataStoreFinder.getAvailableDataStores(); iter.hasNext();){ factoryList.add( iter.next() );
Iterator ps = getAvailableDataStores(); DataStoreFactorySpi fac; while (ps.hasNext()) {
@Test public void testFactorySpi() { Iterator<GeoGigDataStoreFactory> filtered = Iterators .filter(DataStoreFinder.getAvailableDataStores(), GeoGigDataStoreFactory.class); assertTrue(filtered.hasNext()); assertTrue(filtered.next() instanceof GeoGigDataStoreFactory); }
@Test public void testFactorySpi() { Iterator<GeoGigDataStoreFactory> filtered = Iterators .filter(DataStoreFinder.getAvailableDataStores(), GeoGigDataStoreFactory.class); assertTrue(filtered.hasNext()); assertTrue(filtered.next() instanceof GeoGigDataStoreFactory); }