Interface DataSourceFactorySpi

All Superinterfaces:
Factory
All Known Implementing Classes:
AbstractDataSourceFactorySpi, DBCPDataSourceFactory, JNDIDataSourceFactory

public interface DataSourceFactorySpi extends Factory
Constructs a live DataSource from a set of parameters.

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);
 
Author:
Andrea Aime - TOPP
  • Method Details

    • createDataSource

      DataSource createDataSource(Map<String,?> params) throws IOException
      Construct a live data source using the params specifed. The returned DataSource may be pooled.
      Parameters:
      params - The full set of information needed to construct a live DataSource.
      Returns:
      The created DataSource, this may be null if the required resource was not found or if insufficent parameters were given. Note that canProcess() should have returned false if the problem is to do with insuficent parameters.
      Throws:
      IOException - if there were any problems setting up (creating or connecting) the datasource.
    • createNewDataSource

      DataSource createNewDataSource(Map<String,?> params) throws IOException
      Same as createDataSource(Map), but forces the creation of a new DataSource
      Throws:
      IOException
    • getDisplayName

      String getDisplayName()
      Name suitable for display to end user.

      A non localized display name for this data source type.

      Returns:
      A short name suitable for display in a user interface.
    • getDescription

      String getDescription()
      Describe the nature of the data source constructed by this factory.

      A non localized description of this data store type.

      Returns:
      A human readable description that is suitable for inclusion in a list of available datasources.
    • getParametersInfo

      DataAccessFactory.Param[] getParametersInfo()
      MetaData about the required Parameters (for createDataSource(Map)).
      Returns:
      Param array describing the Map for createDataStore
    • canProcess

      boolean canProcess(Map<String,?> params)
      Test to see if this factory is suitable for processing the data pointed to by the params map.

      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.

      Parameters:
      params - The full set of information needed to construct a live data source.
      Returns:
      booean true if and only if this factory can process the resource indicated by the param set and all the required params are pressent.
    • isAvailable

      boolean isAvailable()
      Test to see if this data source is available, if it has all the appropriate libraries to construct a datastore.
      Returns:
      true if and only if this factory has all the appropriate jars on the classpath to create DataSource.