public interface DataStoreFactorySpi extends DataAccessFactory
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" );
An instance of this interface should exist for all data stores which want to take advantage of the dynamic plug-in system. In addition to implementing this factory interface each DataStore implementation should have a services file:
META-INF/services/org.geotools.data.DataStoreFactorySpi
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.
DataAccessFactory.Param
Modifier and Type | Method and Description |
---|---|
DataStore |
createDataStore(Map<String,Serializable> params)
Construct a live data source using the params specifed.
|
DataStore |
createNewDataStore(Map<String,Serializable> params) |
canProcess, getDescription, getDisplayName, getParametersInfo, isAvailable
getImplementationHints
DataStore createDataStore(Map<String,Serializable> params) throws IOException
You can think of this as setting up a connection to the back end data source.
Magic Params: the following params are magic and are honoured by convention by the GeoServer and uDig application.
createDataStore
in interface DataAccessFactory
params
- The full set of information needed to construct a live data store. Typical key
values for the map include: url - location of a resource, used by file reading
datasources. dbtype - the type of the database to connect to, e.g. postgis, mysqlIOException
- if there were any problems setting up (creating or connecting) the
datasource.DataStore createNewDataStore(Map<String,Serializable> params) throws IOException
IOException
Copyright © 1996–2019 Geotools. All rights reserved.