Class ThreadedEpsgFactory

    • Field Detail

      • PRIORITY

        protected static final int PRIORITY
        The default priority level for this factory.
        See Also:
        Constant Field Values
      • datasource

        protected DataSource datasource
        The data source, or null if the connection has not yet been etablished.
      • dynamicDataSource

        protected boolean dynamicDataSource
        Whether the DataSource is created along with the backing store, or it's a stable, long lived one
    • Constructor Detail

      • ThreadedEpsgFactory

        public ThreadedEpsgFactory()
        Constructs an authority factory using the default set of factories.
      • ThreadedEpsgFactory

        public ThreadedEpsgFactory​(Hints userHints)
        Constructs an authority factory with the default priority.
      • ThreadedEpsgFactory

        public ThreadedEpsgFactory​(Hints userHints,
                                   int priority)
        Constructs an authority factory using a set of factories created from the specified hints. This constructor recognizes the CRS, CS, DATUM and MATH_TRANSFORM FACTORY hints, in addition of EPSG_DATA_SOURCE.
        Parameters:
        userHints - An optional set of hints, or null if none.
        priority - The priority for this factory, as a number between MINIMUM_PRIORITY and MAXIMUM_PRIORITY inclusive.
    • Method Detail

      • setDataSource

        public void setDataSource​(DataSource datasource)
                           throws SQLException
        Set the data source for the EPSG database. If an other EPSG database was already in use, it will be disconnected. Users should not invoke this method on the factory returned by ReferencingFactoryFinder, since it could have a system-wide effect.
        Parameters:
        datasource - The new datasource.
        Throws:
        SQLException - if an error occured.
      • createDataSource

        protected DataSource createDataSource()
                                       throws SQLException
        Setup a data source for a connection to the EPSG database. This method is invoked by getDataSource() when no data source has been explicitly set. The default implementation searchs for a DataSource instance binded to the Hints.EPSG_DATA_SOURCE name ("java:comp/env/jdbc/EPSG" by default) using Java Naming and Directory Interfaces (JNDI). If no data source were found, then this method returns null.

        Subclasses override this method in order to initialize a default data source when none were found with JNDI. For example plugin/epsg-access defines a default data source using the JDBC-ODBC bridge, which expects an "EPSG" database registered as an ODBC data source (see the package javadoc for installation instructions). Example for a PostgreSQL data source:

         protected DataSource createDataSource() throws SQLException {
             DataSource candidate = super.createDataSource();
             if (candidate instanceof Jdbc3SimpleDataSource) {
                 return candidate;
             }
             Jdbc3SimpleDataSource ds = new Jdbc3SimpleDataSource();
             ds.setServerName("localhost");
             ds.setDatabaseName("EPSG");
             ds.setUser("postgre");
             return ds;
         }
         
        Returns:
        The EPSG data source, or null if none where found.
        Throws:
        SQLException - if an error occured while creating the data source.
      • createBackingStore

        protected AbstractAuthorityFactory createBackingStore​(Hints hints)
                                                       throws SQLException
        Creates the backing store for the specified data source. This method usually returns a new instance of AccessDialectEpsgFactory or AnsiDialectEpsgFactory. Subclasses may override this method in order to returns an instance tuned for the SQL syntax of the underlying database. Example for a PostgreSQL data source:
         protected AbstractAuthorityFactory createBackingStore(Hints hints) throws SQLException {
             return new AnsiDialectEpsgFactory(hints, getDataSource().getConnection());
         }
         
        Parameters:
        hints - A map of hints, including the low-level factories to use for CRS creation. This argument should be given unchanged to DirectEpsgFactory constructor.
        Returns:
        The EPSG factory using SQL queries appropriate for this data source.
        Throws:
        SQLException - if connection to the database failed.