The following example shows how a user might connect to a PostGIS database, and maintain the resulting datastore in a Registry:
HashMap params = new HashMap(); params.put("namespace", "leeds"); params.put("dbtype", "postgis"); params.put("host","feathers.leeds.ac.uk"); params.put("port", "5432"); params.put("database","postgis_test"); params.put("user","postgis_ro"); params.put("passwd","postgis_ro"); DefaultRegistry registry = new DefaultRegistry(); registry.addDataStore("leeds", params); DataStore postgis = registry.getDataStore( "leeds" ); SimpleFeatureSource = postgis.getFeatureSource( "table" );
The required parameters are described by the getParameterInfo() method. Client An instance of this interface should exist for all DataAccess implementations that want to advantage of the dynamic plug-in system. In addition to implementing this interface a DataAccess implementation should provide a services file:
META-INF/services/org.geotools.data.DataAccessFactory
The file should contain a single line which gives the full name of the implementing class.
Example:e.g. org.geotools.data.mytype.MyTypeDataSourceFacotry
The factories are never called directly by client code, instead the DataStoreFinder class is used.
@author Jody Garnett (Refractions Research) @source $URL$
|
|