public interface DataSourceFactorySpi extends Factory
An instance of this interface should exist for all DataSource providers, common examples being JNDI, DBCP, C3P0. In addition to implementing this interface data source providers should have a services file:
META-INF/services/org.geotools.data.DataSourceFactorySpi
The file should contain a single line which gives the full name of the implementing class.
example:
e.g.
org.geotools.data.dbpc.DBCPDataSourceFactory
The factories are never called directly by client code, instead the DataSourceFinder class is used.
The following example shows how a user might setup a DBCP connection pool::
HashMap params = new HashMap();
params.put("url","jdbc:postgresql://localhost/dbname");
params.put("driverClassName","org.postgresql.Driver");
params.put("username", "5432");
params.put("password","postgis_test");
params.put("maxActive", "10");
DataSource ds = DataSourceFinder.getDataSource(params);
Modifier and Type | Method and Description |
---|---|
boolean |
canProcess(Map params)
Test to see if this factory is suitable for processing the data pointed to by the params map.
|
DataSource |
createDataSource(Map params)
Construct a live data source using the params specifed.
|
DataSource |
createNewDataSource(Map params)
Same as
createDataSource(Map) , but forces the creation of a new DataSource |
String |
getDescription()
Describe the nature of the data source constructed by this factory.
|
String |
getDisplayName()
Name suitable for display to end user.
|
DataAccessFactory.Param[] |
getParametersInfo()
MetaData about the required Parameters (for
createDataSource(Map) ). |
boolean |
isAvailable()
Test to see if this data source is available, if it has all the appropriate libraries to
construct a datastore.
|
getImplementationHints
DataSource createDataSource(Map params) throws IOException
params
- The full set of information needed to construct a live DataSource.IOException
- if there were any problems setting up (creating or connecting) the
datasource.DataSource createNewDataSource(Map params) throws IOException
createDataSource(Map)
, but forces the creation of a new DataSourceparams
- IOException
String getDisplayName()
A non localized display name for this data source type.
String getDescription()
A non localized description of this data store type.
DataAccessFactory.Param[] getParametersInfo()
createDataSource(Map)
).boolean canProcess(Map params)
If this data source requires a number of parameters then this mehtod should check that they are all present and that they are all valid.
params
- The full set of information needed to construct a live data source.boolean isAvailable()
Copyright © 1996–2019 Geotools. All rights reserved.