org.geotools.referencing.factory.epsg
Class ThreadedEpsgFactory
Object
AbstractFactory
ReferencingFactory
AbstractAuthorityFactory
BufferedAuthorityFactory
DeferredAuthorityFactory
ThreadedEpsgFactory
- All Implemented Interfaces:
- RegisterableService, BufferedFactory, Factory, OptionalFactory, AuthorityFactory, CRSAuthorityFactory, CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory
- Direct Known Subclasses:
- DefaultFactory, ThreadedHsqlEpsgFactory, ThreadedPostgreSQLEpsgFactory
public class ThreadedEpsgFactory
- extends DeferredAuthorityFactory
- implements CRSAuthorityFactory, CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory
Base class for EPSG factories to be registered in ReferencingFactoryFinder
.
Various subclasses are defined for different database backends: Access, PostgreSQL,
HSQL, etc..
This class has the following responsibilities:
- aquire a DataSource (using JNDI or otherwise)
- specify a worker class that will talk to the database in
the event of a cache miss. The class will be specific to the delect of SQL
used by the database hosting the EPSG tables.
Please note we are working with the same tables as defined by EPSG. The only
thing that changes is the database used to host these tables.
Subclasses should override the following methods:
Users should not creates instance of this class directly. They should invoke one of
ReferencingFactoryFinder.getFooAuthorityFactory("EPSG")
methods instead.
- Since:
- 2.4
- Author:
- Martin Desruisseaux (IRD)
- Module:
modules/library/referencing (gt-referencing.jar)
Constructor Summary |
ThreadedEpsgFactory()
Constructs an authority factory using the default set of factories. |
ThreadedEpsgFactory(Hints userHints)
Constructs an authority factory with the default priority. |
ThreadedEpsgFactory(Hints userHints,
int priority)
Constructs an authority factory using a set of factories created from the specified hints. |
Methods inherited from class BufferedAuthorityFactory |
createCartesianCS, createCompoundCRS, createCoordinateOperation, createCoordinateReferenceSystem, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createDatum, createDerivedCRS, createEllipsoid, createEllipsoidalCS, createEngineeringCRS, createEngineeringDatum, createExtent, createFromCoordinateReferenceSystemCodes, createGeocentricCRS, createGeodeticDatum, createGeographicCRS, createImageCRS, createImageDatum, createObject, createOperationMethod, createParameterDescriptor, createPolarCS, createPrimeMeridian, createProjectedCRS, createSphericalCS, createTemporalCRS, createTemporalDatum, createTimeCS, createUnit, createVerticalCRS, createVerticalCS, createVerticalDatum, getAuthorityCodes, getBackingStoreDescription, getDescriptionText, getIdentifiedObjectFinder, getVendor |
DATASOURCE_NAME
public static final String DATASOURCE_NAME
- The default JDBC data source name in JNDI.
This is the name used if no other name were specified through the
EPSG_DATA_SOURCE
hint.
- See Also:
createDataSource()
,
Constant Field Values
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.
getAuthority
public Citation getAuthority()
- Returns the authority for this EPSG database.
This authority will contains the database version in the edition attribute, together with the edition date.
- Specified by:
getAuthority
in interface AuthorityFactory
- Overrides:
getAuthority
in class BufferedAuthorityFactory
getDataSource
public final DataSource getDataSource()
throws SQLException
- Returns the data source for the EPSG database. If no data source has been previously
set, then this method invokes
createDataSource()
.
Note: invoking this method may force immediate connection to the EPSG
database.
- Returns:
- The data source.
- Throws:
SQLException
- if the connection to the EPSG database failed.- See Also:
setDataSource(javax.sql.DataSource)
,
createDataSource()
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.
createBackingStore
protected AbstractAuthorityFactory createBackingStore()
throws FactoryException
- Creates the backing store authority factory.
- Specified by:
createBackingStore
in class DeferredAuthorityFactory
- Returns:
- The backing store to uses in
createXXX(...)
methods.
- Throws:
FactoryException
- if the constructor failed to connect to the EPSG database.
This exception usually has a SQLException
as its cause.
canDisposeBackingStore
protected boolean canDisposeBackingStore(AbstractAuthorityFactory backingStore)
- Returns
true
if the backing store can be disposed now. This method is invoked
automatically after the amount of time specified by DeferredAuthorityFactory.setTimeout(long)
if the factory
were not used during that time.
- Overrides:
canDisposeBackingStore
in class DeferredAuthorityFactory
- Parameters:
backingStore
- The backing store in process of being disposed.
Copyright © 1996-2010 Geotools. All Rights Reserved.