public class ThreadedEpsgFactory extends DeferredAuthorityFactory implements CRSAuthorityFactory, CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory
ReferencingFactoryFinder
. Various
subclasses are defined for different database backends: Access, PostgreSQL, HSQL,
etc..
This class has the following responsibilities:
Subclasses should override the following methods:
createBackingStore(org.geotools.util.factory.Hints)
instance capable to speak that database syntax
Users should not creates instance of this class directly. They should invoke one of
ReferencingFactoryFinder.getFooAuthorityFactory("EPSG")
methods instead.
Modifier and Type | Field and Description |
---|---|
protected DataSource |
datasource
The data source, or
null if the connection has not yet been etablished. |
static String |
DATASOURCE_NAME
The default JDBC data source name in JNDI.
|
protected boolean |
dynamicDataSource
Whether the DataSource is created along with the backing store, or it's a stable, long lived
one
|
protected static int |
PRIORITY
The default priority level for this factory.
|
LOGGER
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
canDisposeBackingStore(AbstractAuthorityFactory backingStore)
Returns
true if the backing store can be disposed now. |
protected AbstractAuthorityFactory |
createBackingStore()
Creates the backing store authority factory.
|
protected AbstractAuthorityFactory |
createBackingStore(Hints hints)
Creates the backing store for the specified data source.
|
protected DataSource |
createDataSource()
Setup a data source for a connection to the EPSG database.
|
void |
dispose()
Releases resources immediately instead of waiting for the garbage collector.
|
protected void |
disposeBackingStore()
Disposes of the backing store
|
Citation |
getAuthority()
Returns the authority for this EPSG database.
|
DataSource |
getDataSource()
Returns the data source for the EPSG database.
|
void |
setDataSource(DataSource datasource)
Set the data source for the EPSG database.
|
exit, getBackingStore, isAvailable, isConnected, setTimeout
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
noSuchAuthorityCode, trimAuthority
ensureNonNull
addImplementationHints, equals, getImplementationHints, getPriority, hashCode, onDeregistration, onRegistration, toString
createCompoundCRS, createCoordinateReferenceSystem, createDerivedCRS, createEngineeringCRS, createGeocentricCRS, createGeographicCRS, createImageCRS, createProjectedCRS, createTemporalCRS, createVerticalCRS
createCartesianCS, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createEllipsoidalCS, createPolarCS, createSphericalCS, createTimeCS, createUnit, createVerticalCS
createDatum, createEllipsoid, createEngineeringDatum, createGeodeticDatum, createImageDatum, createPrimeMeridian, createTemporalDatum, createVerticalDatum
createCoordinateOperation, createFromCoordinateReferenceSystemCodes
createObject, getAuthorityCodes, getDescriptionText
getImplementationHints
public static final String DATASOURCE_NAME
EPSG_DATA_SOURCE
hint.createDataSource()
,
Constant Field Valuesprotected static final int PRIORITY
protected DataSource datasource
null
if the connection has not yet been etablished.protected boolean dynamicDataSource
public ThreadedEpsgFactory()
public ThreadedEpsgFactory(Hints userHints)
public ThreadedEpsgFactory(Hints userHints, int priority)
CRS
, CS
,
DATUM
and MATH_TRANSFORM
FACTORY
hints, in addition of EPSG_DATA_SOURCE
.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.public Citation getAuthority()
getAuthority
in interface AuthorityFactory
getAuthority
in class BufferedAuthorityFactory
public final DataSource getDataSource() throws SQLException
createDataSource()
.
Note: invoking this method may force immediate connection to the EPSG
database.SQLException
- if the connection to the EPSG database failed.setDataSource(javax.sql.DataSource)
,
createDataSource()
public void setDataSource(DataSource datasource) throws SQLException
ReferencingFactoryFinder
, since it could have a system-wide effect.datasource
- The new datasource.SQLException
- if an error occured.protected DataSource createDataSource() throws SQLException
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; }
null
if none where found.SQLException
- if an error occured while creating the data source.protected AbstractAuthorityFactory createBackingStore(Hints hints) throws SQLException
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()); }
hints
- A map of hints, including the low-level factories to use for CRS creation. This
argument should be given unchanged to DirectEpsgFactory
constructor.SQLException
- if connection to the database failed.protected AbstractAuthorityFactory createBackingStore() throws FactoryException
createBackingStore
in class DeferredAuthorityFactory
createXXX(...)
methods.FactoryException
- if the constructor failed to connect to the EPSG database. This
exception usually has a SQLException
as its cause.protected boolean canDisposeBackingStore(AbstractAuthorityFactory backingStore)
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.canDisposeBackingStore
in class DeferredAuthorityFactory
backingStore
- The backing store in process of being disposed.protected void disposeBackingStore()
DeferredAuthorityFactory
disposeBackingStore
in class DeferredAuthorityFactory
public void dispose() throws FactoryException
DeferredAuthorityFactory
DeferredAuthorityFactory.canDisposeBackingStore(org.geotools.referencing.factory.AbstractAuthorityFactory)
value.dispose
in class DeferredAuthorityFactory
FactoryException
- if an error occured while disposing the factory.Copyright © 1996–2019 Geotools. All rights reserved.