|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectFactory
ReferencingFactory
AbstractAuthorityFactory
CachingAuthorityFactory
ThreadedAuthorityFactory
ThreadedEpsgFactory
@ThreadSafe public class ThreadedEpsgFactory
The EPSG factory registered in AuthorityFactoryFinder.
This class has the following responsibilities:
Note that we are working with the same tables as defined by EPSG. The only thing that changes is the database used to host these tables, and optionally the schema and table names. The EPSG database version can be determined by the edition attribute of the authority.
Users should not creates instance of this class directly. They should invoke one of
AuthorityFactoryFinder.getFooAuthorityFactory("EPSG") methods
instead, unless they want to derive their own subclass. In the later case, the following
methods are good candidate for overriding:
createDataSource(Properties) used to create a default DataSource
when none was explicitly specified by the user (typically as a hint).createBackingStore(Hints) used to create a worker instance capable
to speak the SQL dialect of that database.
DirectEpsgFactory,
List of authority codes
| referencing/geotk-referencing (download) | View source code for this class |
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class Factory |
|---|
Factory.Availability, Factory.Organizer |
| Field Summary | |
|---|---|
static String |
CONFIGURATION_FILE
The user configuration file, which is "EPSG-DataSource.properties". |
protected String |
password
The password to be given to DataSource.getConnection(String,String), or null
if none. |
protected String |
schema
The name of the schema in the database where to look for the tables, or null if none. |
protected String |
user
The user name to be given to DataSource.getConnection(String,String), or null
if none. |
| Fields inherited from class AbstractAuthorityFactory |
|---|
nameFactory |
| Fields inherited from class ReferencingFactory |
|---|
LOGGER |
| Fields inherited from class Factory |
|---|
EMPTY_HINTS, hints |
| Constructor Summary | |
|---|---|
ThreadedEpsgFactory()
Constructs an authority factory using the default set of factories. |
|
ThreadedEpsgFactory(DataSource source)
Constructs an authority factory which will connect to an EPSG database using the given data source. |
|
ThreadedEpsgFactory(Hints userHints)
Constructs an authority factory using a set of factories created from the specified hints. |
|
| Method Summary | |
|---|---|
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 current data source. |
protected DataSource |
createDataSource(Properties properties)
Creates a default data source, optionally using the given configuration. |
protected void |
dispose(boolean shutdown)
Releases resources immediately instead of waiting for the garbage collector. |
protected DataSource |
getDataSource()
Returns the data source for the EPSG database. |
static String |
getDefaultURL()
Returns the default JDBC URL to use for connection to the EPSG embedded database. |
| Methods inherited from class ThreadedAuthorityFactory |
|---|
getImplementationHints, getTimeout, isActive, setTimeout |
| Methods inherited from class AbstractAuthorityFactory |
|---|
noSuchAuthorityCode, trimAuthority |
| Methods inherited from class ReferencingFactory |
|---|
ensureNonNull |
| Methods inherited from class Factory |
|---|
equals, hasCompatibleHints, hashCode, setOrdering, toString |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface CRSAuthorityFactory |
|---|
createCompoundCRS, createCoordinateReferenceSystem, createDerivedCRS, createEngineeringCRS, createGeocentricCRS, createGeographicCRS, createImageCRS, createProjectedCRS, createTemporalCRS, createVerticalCRS |
| Methods inherited from interface CSAuthorityFactory |
|---|
createCartesianCS, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createEllipsoidalCS, createPolarCS, createSphericalCS, createTimeCS, createUnit, createVerticalCS |
| Methods inherited from interface DatumAuthorityFactory |
|---|
createDatum, createEllipsoid, createEngineeringDatum, createGeodeticDatum, createImageDatum, createPrimeMeridian, createTemporalDatum, createVerticalDatum |
| Methods inherited from interface CoordinateOperationAuthorityFactory |
|---|
createCoordinateOperation, createFromCoordinateReferenceSystemCodes, createOperationMethod |
| Methods inherited from interface AuthorityFactory |
|---|
createObject, getAuthority, getAuthorityCodes, getDescriptionText |
| Methods inherited from interface Factory |
|---|
getVendor |
| Field Detail |
|---|
public static final String CONFIGURATION_FILE
DataSource
object were specified explicitly to the constructor, either directly or as a hint. In such
case, ThreadedEpsgFactory will look for the first of the following files:
"EPSG-DataSource.properties" in the current directory"EPSG-DataSource.properties" in the user's home directory"EPSG/DataSource.properties" in the Geotk application data directoryThis file should contain the properties listed below.
| Property | Type | Description |
|---|---|---|
URL |
String |
URL to the database. |
schema |
String |
The schema for the EPSG tables. |
user |
String |
User used to make database connections. |
password |
String |
Password used to make database connections. |
protected String schema
null if none.
This property is read from the "EPSG-DataSource.properties" file by getDataSource(),
and is used by createBackingStore(Hints). If a subclass wants to change this value,
then overriding the createDataSource(Properties) method is a convenient way to do so.
protected String user
DataSource.getConnection(String,String), or null
if none. In the later case, DataSource.getConnection() will be used instead.
This property is read from the "EPSG-DataSource.properties" file by getDataSource(),
and is used by createBackingStore(Hints). If a subclass wants to change this value,
then overriding the createDataSource(Properties) method is a convenient way to do so.
protected String password
DataSource.getConnection(String,String), or null
if none.
This property is read from the "EPSG-DataSource.properties" file by getDataSource(),
and is used by createBackingStore(Hints). If a subclass wants to change this value,
then overriding the createDataSource(Properties) method is a convenient way to do so.
| Constructor Detail |
|---|
public ThreadedEpsgFactory()
Hints.EPSG_DATA_SOURCE
in the system default hints, if any.
public ThreadedEpsgFactory(DataSource source)
PGSimpleDataSource source = new PGSimpleDataSource();
ds.setServerName("localhost");
ds.setDatabaseName("EPSG");
ds.setUser("postgre");
source - The data source for the EPSG database, or null.public ThreadedEpsgFactory(Hints userHints)
This constructor recognizes also the CRS, CS,
DATUM and MATH_TRANSFORM
FACTORY hints.
userHints - An optional set of hints, or null for the default ones.| Method Detail |
|---|
public static String getDefaultURL()
If no database exists in the above-cited directory, then a new EPSG database will be
created by ThreadedEpsgFactory when first needed provided that the
geotk-epsg
module is reachable on the classpath.
Note that the directory may change in any Geotk version. More specifically, every upgrade of the embedded EPSG database may cause a change of the default directory.
protected DataSource getDataSource()
throws FactoryException
If a DataSource object was given explicitly to the constructor, it is
returned.
Otherwise if hint value is associated to the Hints.EPSG_DATA_SOURCE key,
then there is a choice:
DataSource, it is returned.Name, then a
JNDI lookup is performed for that name.String, then a
JNDI lookup is performed for that name.Otherwise if at least one of the following files exist, then the first one is used
for etablishing a connection (See CONFIGURATION_FILE for more informations).
"EPSG-DataSource.properties" in the current directory"EPSG-DataSource.properties" in the user's home directory"EPSG/DataSource.properties" in the Geotk application data directoryOtherwise the default URL to the embedded database
is used. If the database does not exist and the geotk-epsg.jar file is
reachable on the classpath, then the EPSG database will be created when first
needed.
createDataSource(Properties).
Subclasses can override that method if they want more control on that part (for example in
order to perform different tasks depending the content of the properties file).
null.
FactoryException - if the operation failed (for example an I/O error while
reading the configuration file, or a failure to lookup the JNDI name).
protected DataSource createDataSource(Properties properties)
throws FactoryException
getDataSource() when no explicit value was provided for
Hints.EPSG_DATA_SOURCE. If a configuration file
has been found, its content is given as the sole argument to this method. Otherwise the
properties argument is null.
The default implementation performs the following steps:
properties is non-null, then the value associated to the "URL"
key is taken. Otherwise the default URL to the embedded
database is used.DataSource is created, which will use the above URL for fetching a
connection through DriverManager.getConnection(String).
If the default URL was used and no database exists at that URL, then a new database will
be created using the EpsgInstaller when first needed. This operation is possible
only if the geotk-epsg.jar file is reachable on the classpath, otherwise an
exception will be thrown the first time the factory will be used.
Subclasses should override this method if they can create a data source from other
properties ("serverName", "databaseName", etc.), or if
they can provide a default data source.
properties - The properties loaded from the configuration file if it was found,
or null otherwise.
null if this method
can not create a data source.
FactoryException - if the operation failed for an other reason.
protected AbstractAuthorityFactory createBackingStore(Hints hints)
throws FactoryException,
SQLException
DirectEpsgFactory from the database metadata.
Subclasses should override this method if they can return an instance tuned for the
SQL dialect of the underlying database. Example for a Oracle data source:
protected AbstractAuthorityFactory createBackingStore(Hints hints) throws SQLException {
return new OracleDialectEpsgFactory(hints, getDataSource().getConnection(user, password));
}
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 the connection to the database failed.
FactoryException - if the operation failed for an other reason (for example a
failure to get the data source).user,
password
protected AbstractAuthorityFactory createBackingStore()
throws FactoryException
ThreadedAuthorityFactory when a new backing store is required, either
because the previous one has been disposed after its timeout or because a new one
is required for concurrency.
The default implementation invokes createBackingStore(Hints) with a map
of hints derived from this factory hints, then logs a message
at the CONFIG level. The log message contains the URL to the
database.
createBackingStore in class ThreadedAuthorityFactorycreateXXX(...) 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 ThreadedAuthorityFactory.setTimeout(long) if the factory
were not used during that time.
canDisposeBackingStore in class ThreadedAuthorityFactorybackingStore - The backing store in process of being disposed.
true if the backing store can be disposed now.protected void dispose(boolean shutdown)
dispose in class ThreadedAuthorityFactoryshutdown - false for normal disposal, or true if this method is invoked
during the process of a JVM shutdown. In the later case this method may shutdown the
embedded database, if there is one (for example JavaDB).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||