/** * Checks if the feature type cache contents needs updating, does so in case. The code assumes * the caller already owns a read only lock that needs upgrading in case the information is * stale. */ private void updateCache() throws IOException { if (watcher.isStale()) { // upgrade lock so that we have exclusive access to ftCache lock.readLock().unlock(); lock.writeLock().lock(); try { // still stale? if (watcher.isStale()) { watcher.mark(); refreshCacheContents(); } } finally { // downgrade lock lock.readLock().lock(); lock.writeLock().unlock(); } } }
public void createSchema(SimpleFeatureType featureType) throws IOException { File f = new File(cache.directory, featureType.getTypeName() + ".shp"); Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put("url", URLs.fileToUrl(f)); params.put("filetype", "shapefile"); DataStore ds = null; try { ds = DataStoreFinder.getDataStore(params); if (ds != null) { ds.createSchema(featureType); ds.dispose(); cache.refreshCacheContents(); } } catch (Exception e) { throw (IOException) new IOException("Error creating new data store").initCause(e); } if (ds == null) { throw new IOException("Could not find the shapefile data store in the classpath"); } }
public void createSchema(SimpleFeatureType featureType) throws IOException { File f = new File(cache.directory, featureType.getTypeName()+".shp"); String shpDataStoreClassName = "org.geotools.data.shapefile.ShapefileDataStore"; DataStore ds = null; try { ds = (DataStore) Class.forName(shpDataStoreClassName).getConstructor(URL.class) .newInstance(f.toURL()); ds.createSchema(featureType); cache.refreshCacheContents(); } catch(Exception e) { throw (IOException) new IOException("Error creating new data store").initCause(e); } }
/** * Checks if the feature type cache contents needs updating, does so in case. * The code assumes the caller already owns a read only lock that needs upgrading * in case the information is stale. */ private void updateCache() throws IOException { if(watcher.isStale()) { // upgrade lock so that we have exclusive access to ftCache lock.readLock().unlock(); lock.writeLock().lock(); try { // still stale? if(watcher.isStale()) { watcher.mark(); refreshCacheContents(); } } finally { // downgrade lock lock.readLock().lock(); lock.writeLock().unlock(); } } }
/** * Checks if the feature type cache contents needs updating, does so in case. * The code assumes the caller already owns a read only lock that needs upgrading * in case the information is stale. */ private void updateCache() throws IOException { if(watcher.isStale()) { // upgrade lock so that we have exclusive access to ftCache lock.readLock().unlock(); lock.writeLock().lock(); try { // still stale? if(watcher.isStale()) { watcher.mark(); refreshCacheContents(); } } finally { // downgrade lock lock.readLock().lock(); lock.writeLock().unlock(); } } }
public void createSchema(SimpleFeatureType featureType) throws IOException { File f = new File(cache.directory, featureType.getTypeName()+".shp"); Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put("url", DataUtilities.fileToURL(f)); params.put("filetype", "shapefile"); DataStore ds = null; try { ds = DataStoreFinder.getDataStore(params); if(ds != null) { ds.createSchema(featureType); ds.dispose(); cache.refreshCacheContents(); } } catch(Exception e) { throw (IOException) new IOException("Error creating new data store").initCause(e); } if(ds == null) { throw new IOException("Could not find the shapefile data store in the classpath"); } }