Class ConcurrentAuthorityFactory<DAO extends GeodeticAuthorityFactory>
- Type Parameters:
DAO
- the type of factory used as Data Access Object (DAO).
- All Implemented Interfaces:
AutoCloseable
,AuthorityFactory
,Factory
- Direct Known Subclasses:
EPSGFactory
createFoo(String)
methods first check if a previously created object exists for the given code.
If such object exists, it is returned. Otherwise, the object creation is delegated to another factory given
by newDataAccess()
and the result is cached in this factory.
ConcurrentAuthorityFactory
delays the call to newDataAccess()
until first needed,
and closes the factory used as a Data Access Object
(DAO) after some timeout. This approach allows to establish a connection to a database (for example)
and keep it only for a relatively short amount of time.
Caching strategy
Objects are cached by strong references, up to the amount of objects specified at construction time. If a greater amount of objects are cached, then the oldest ones will be retained through a weak reference instead of a strong one. This means that this caching factory will continue to return those objects as long as they are in use somewhere else in the Java virtual machine, but will be discarded (and recreated on the fly if needed) otherwise.Multi-threading
The cache managed by this class is concurrent. However, the Data Access Objects (DAO) are assumed non-concurrent. If two or more threads are accessing this factory at the same time, then two or more Data Access Object instances may be created. The maximal amount of instances to create is specified atConcurrentAuthorityFactory
construction time. If more Data Access Object instances are needed, some of the threads will block until an
instance become available.
Note for subclasses
This abstract class does not implement any of theDatumAuthorityFactory
, CSAuthorityFactory
,
CRSAuthorityFactory
and CoordinateOperationAuthorityFactory
interfaces.
Subclasses should select the interfaces that they choose to implement.- Since:
- 0.7
-
Constructor Summary
ModifierConstructorDescriptionprotected
ConcurrentAuthorityFactory
(Class<DAO> dataAccessClass) Constructs an instance with a default number of threads and a default number of entries to keep by strong references.protected
ConcurrentAuthorityFactory
(Class<DAO> dataAccessClass, int maxStrongReferences, int maxConcurrentQueries) Constructs an instance with the specified number of entries to keep by strong references. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Returnstrue
if the given Data Access Object (DAO) can be closed.void
close()
Immediately closes all Data Access Objects that are closeable.createCartesianCS
(String code) Returns a 2- or 3-dimensional Cartesian coordinate system made of straight orthogonal axes.createCompoundCRS
(String code) Returns a CRS describing the position of points through two or more independent coordinate reference systems.Returns an operation for transforming coordinates in the source CRS to coordinates in the target CRS.Returns an arbitrary coordinate reference system from a code.Returns an arbitrary coordinate system from a code.Returns a coordinate system axis with name, direction, unit and range of values.createCylindricalCS
(String code) Returns a 3-dimensional coordinate system made of a polar coordinate system extended by a straight perpendicular axis.createDatum
(String code) Returns an arbitrary datum from a code.createDerivedCRS
(String code) Returns a CRS that is defined by its coordinate conversion from another CRS (not by a datum).createEllipsoid
(String code) Returns a geometric figure that can be used to describe the approximate shape of the earth.createEllipsoidalCS
(String code) Returns a 2- or 3-dimensional coordinate system for geodetic latitude and longitude, sometimes with ellipsoidal height.createEngineeringCRS
(String code) Returns a 1-, 2- or 3-dimensional contextually local coordinate reference system.Returns a datum defining the origin of an engineering coordinate reference system.createExtent
(String code) Returns information about spatial, vertical, and temporal extent (usually a domain of validity) from a code.createFromCoordinateReferenceSystemCodes
(String sourceCRS, String targetCRS) Returns operations from source and target coordinate reference system codes.createGeocentricCRS
(String code) Returns a 3-dimensional coordinate reference system with the origin at the approximate centre of mass of the earth.createGeodeticDatum
(String code) Returns a datum defining the location and orientation of an ellipsoid that approximates the shape of the earth.createGeographicCRS
(String code) Returns a 2- or 3-dimensional coordinate reference system based on an ellipsoidal approximation of the geoid.createImageCRS
(String code) Returns a 2-dimensional engineering coordinate reference system applied to locations in images.createImageDatum
(String code) Returns a datum defining the origin of an image coordinate reference system.createObject
(String code) Returns an arbitrary object from a code.Returns a description of the algorithm and parameters used to perform a coordinate operation.Returns a definition of a single parameter used by an operation method.createPolarCS
(String code) Returns a 2-dimensional coordinate system for coordinates represented by a distance from the origin and an angle from a fixed direction.createPrimeMeridian
(String code) Returns a prime meridian defining the origin from which longitude values are determined.createProjectedCRS
(String code) Returns a 2-dimensional coordinate reference system used to approximate the shape of the earth on a planar surface.createSphericalCS
(String code) Returns a 3-dimensional coordinate system with one distance measured from the origin and two angular coordinates.createTemporalCRS
(String code) Returns a 1-dimensional coordinate reference system used for the recording of time.createTemporalDatum
(String code) Returns a datum defining the origin of a temporal coordinate reference system.createTimeCS
(String code) Returns a 1-dimensional coordinate system for heights or depths of points.Unit
<?> createUnit
(String code) Returns an unit of measurement from a code.createVerticalCRS
(String code) Returns a 1-dimensional coordinate reference system used for recording heights or depths.createVerticalCS
(String code) Returns a 1-dimensional coordinate system for heights or depths of points.createVerticalDatum
(String code) Returns a datum identifying a particular reference level surface used as a zero-height surface.Returns the database or specification that defines the codes recognized by this factory.getAuthorityCodes
(Class<? extends IdentifiedObject> type) Returns the set of authority codes for objects of the given type.getDescriptionText
(String code) Gets a description of the object corresponding to a code.long
getTimeout
(TimeUnit unit) Returns the amount of time thatConcurrentAuthorityFactory
will wait before to close a Data Access Object.protected boolean
isCacheable
(String code, Object object) Returns whether the given object can be cached.protected abstract DAO
Creates a factory which will perform the actual geodetic object creation work.Returns a finder which can be used for looking up unidentified objects.protected String
normalizeCode
(String code) Returns a code equivalent to the given code but with unnecessary elements eliminated.void
Prints the cache content to the given writer.void
setTimeout
(long delay, TimeUnit unit) Sets a timer for closing the Data Access Object after the specified amount of time of inactivity.Returns a string representation of this factory for debugging purpose only.Methods inherited from class GeodeticAuthorityFactory
createParametricCRS, createParametricCS, createParametricDatum, getCodeSpaces, trimNamespace
Methods inherited from class AbstractFactory
getVendor
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface Factory
getVendor
-
Constructor Details
-
ConcurrentAuthorityFactory
Constructs an instance with a default number of threads and a default number of entries to keep by strong references. Note that those default values may change in any future SIS versions based on experience gained.- Parameters:
dataAccessClass
- the class of Data Access Object (DAO) created bynewDataAccess()
.
-
ConcurrentAuthorityFactory
protected ConcurrentAuthorityFactory(Class<DAO> dataAccessClass, int maxStrongReferences, int maxConcurrentQueries) Constructs an instance with the specified number of entries to keep by strong references. If a number of object greater thanmaxStrongReferences
are created, then the strong references for the eldest objects will be replaced by weak references.- Parameters:
dataAccessClass
- the class of Data Access Object (DAO) created bynewDataAccess()
.maxStrongReferences
- the maximum number of objects to keep by strong reference.maxConcurrentQueries
- the maximal amount of Data Access Objects to use concurrently. If more than this amount of threads are querying thisConcurrentAuthorityFactory
concurrently, additional threads will be blocked until a Data Access Object become available.
-
-
Method Details
-
newDataAccess
Creates a factory which will perform the actual geodetic object creation work. This method is invoked the first time acreateFoo(String)
method is invoked. It may also be invoked again if additional factories are needed in different threads, or if all factories have been closed after the timeout.Multi-threading
This method (but not necessarily the returned factory) needs to be thread-safe;ConcurrentAuthorityFactory
does not hold any lock when invoking this method. Subclasses are responsible to apply their own synchronization if needed, but are encouraged to avoid doing so if possible. In addition, implementations should not invoke otherConcurrentAuthorityFactory
methods during this method execution in order to avoid never-ending loop.- Returns:
- Data Access Object (DAO) to use in
createFoo(String)
methods. - Throws:
UnavailableFactoryException
- if the Data Access Object is unavailable because an optional resource is missing.FactoryException
- if the creation of Data Access Object failed for another reason.
-
canClose
Returnstrue
if the given Data Access Object (DAO) can be closed. This method is invoked automatically after the timeout if the given DAO has been idle during all that time. Subclasses can override this method and returnfalse
if they want to prevent the DAO disposal under some circumstances.The default implementation always returns
true
.- Parameters:
factory
- the Data Access Object which is about to be closed.- Returns:
true
if the given Data Access Object can be closed.- See Also:
-
getTimeout
Returns the amount of time thatConcurrentAuthorityFactory
will wait before to close a Data Access Object. This delay is measured from the last time the Data Access Object has been used by acreateFoo(String)
method.- Parameters:
unit
- the desired unit of measurement for the timeout.- Returns:
- the current timeout in the given unit of measurement.
-
setTimeout
Sets a timer for closing the Data Access Object after the specified amount of time of inactivity. If a new Data Access Object is needed after the disposal of the last one, then thenewDataAccess()
method will be invoked again.- Parameters:
delay
- the delay of inactivity before to close a Data Access Object.unit
- the unit of measurement of the given delay.
-
getAuthority
Returns the database or specification that defines the codes recognized by this factory. The default implementation performs the following steps:- Returns the cached value if it exists.
- Otherwise:
- get an instance of the Data Access Object,
- delegate to its
GeodeticAuthorityFactory.getAuthority()
method, - release the Data Access Object,
- cache the result.
null
.- Specified by:
getAuthority
in interfaceAuthorityFactory
- Specified by:
getAuthority
in classGeodeticAuthorityFactory
- Returns:
- the organization responsible for definition of the database, or
null
if unavailable. - See Also:
-
getAuthorityCodes
public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type) throws FactoryException Returns the set of authority codes for objects of the given type. The default implementation performs the following steps:- get an instance of the Data Access Object,
- delegate to its
AuthorityFactory.getAuthorityCodes(Class)
method, - release the Data Access Object.
- Specified by:
getAuthorityCodes
in interfaceAuthorityFactory
- Parameters:
type
- the spatial reference objects type (e.g.ProjectedCRS.class
).- Returns:
- the set of authority codes for spatial reference objects of the given type. If this factory does not contains any object of the given type, then this method returns an empty set.
- Throws:
FactoryException
- if access to the underlying database failed.
-
getDescriptionText
public InternationalString getDescriptionText(String code) throws NoSuchAuthorityCodeException, FactoryException Gets a description of the object corresponding to a code. The default implementation performs the following steps:- get an instance of the Data Access Object,
- delegate to its
GeodeticAuthorityFactory.getDescriptionText(String)
method, - release the Data Access Object.
- Specified by:
getDescriptionText
in interfaceAuthorityFactory
- Overrides:
getDescriptionText
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- a description of the object, or
null
if the object corresponding to the specifiedcode
has no description. - Throws:
NoSuchAuthorityCodeException
- if the specifiedcode
was not found.FactoryException
- if the query failed for some other reason.
-
normalizeCode
Returns a code equivalent to the given code but with unnecessary elements eliminated. The normalized code is used as the key in the cache, and is also the code which will be passed to the Data Access Object (DAO).The default implementation performs the following steps:
- Removes the namespace if presents. For example if the codespace
is EPSG and the given code starts with the
"EPSG:"
prefix, then that prefix is removed. - Removes leading and trailing spaces.
- Parameters:
code
- the code to normalize.- Returns:
- the normalized code.
- Throws:
FactoryException
- if an error occurred while normalizing the given code.
- Removes the namespace if presents. For example if the codespace
is EPSG and the given code starts with the
-
createObject
Returns an arbitrary object from a code. The default implementation performs the following steps:- Returns the cached instance for the given code if such instance already exists.
- Otherwise:
- get an instance of the Data Access Object,
- delegate to its
GeodeticAuthorityFactory.createObject(String)
method, - release the Data Access Object,
- cache the result.
- Specified by:
createObject
in interfaceAuthorityFactory
- Specified by:
createObject
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the object for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createCoordinateReferenceSystem
public CoordinateReferenceSystem createCoordinateReferenceSystem(String code) throws FactoryException Returns an arbitrary coordinate reference system from a code. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createCoordinateReferenceSystem(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createCoordinateReferenceSystem(String)
method in the parent class. This allows to check if the more genericcreateObject(String)
method cached a value before to try that method.
- Overrides:
createCoordinateReferenceSystem
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createGeographicCRS
Returns a 2- or 3-dimensional coordinate reference system based on an ellipsoidal approximation of the geoid. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createGeographicCRS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createGeographicCRS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateReferenceSystem(String)
method cached a value before to try that method.
- Overrides:
createGeographicCRS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createGeocentricCRS
Returns a 3-dimensional coordinate reference system with the origin at the approximate centre of mass of the earth. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createGeocentricCRS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createGeocentricCRS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateReferenceSystem(String)
method cached a value before to try that method.
- Overrides:
createGeocentricCRS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createProjectedCRS
Returns a 2-dimensional coordinate reference system used to approximate the shape of the earth on a planar surface. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createProjectedCRS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createProjectedCRS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateReferenceSystem(String)
method cached a value before to try that method.
- Overrides:
createProjectedCRS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createVerticalCRS
Returns a 1-dimensional coordinate reference system used for recording heights or depths. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createVerticalCRS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createVerticalCRS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateReferenceSystem(String)
method cached a value before to try that method.
- Overrides:
createVerticalCRS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createTemporalCRS
Returns a 1-dimensional coordinate reference system used for the recording of time. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createTemporalCRS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createTemporalCRS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateReferenceSystem(String)
method cached a value before to try that method.
- Overrides:
createTemporalCRS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createCompoundCRS
Returns a CRS describing the position of points through two or more independent coordinate reference systems. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createCompoundCRS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createCompoundCRS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateReferenceSystem(String)
method cached a value before to try that method.
- Overrides:
createCompoundCRS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createDerivedCRS
Returns a CRS that is defined by its coordinate conversion from another CRS (not by a datum). The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createDerivedCRS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createDerivedCRS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateReferenceSystem(String)
method cached a value before to try that method.
- Overrides:
createDerivedCRS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createEngineeringCRS
Returns a 1-, 2- or 3-dimensional contextually local coordinate reference system. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createEngineeringCRS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createEngineeringCRS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateReferenceSystem(String)
method cached a value before to try that method.
- Overrides:
createEngineeringCRS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createImageCRS
Returns a 2-dimensional engineering coordinate reference system applied to locations in images. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createImageCRS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createImageCRS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateReferenceSystem(String)
method cached a value before to try that method.
- Overrides:
createImageCRS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate reference system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createDatum
Returns an arbitrary datum from a code. The returned object will typically be an The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createDatum(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createDatum(String)
method in the parent class. This allows to check if the more genericcreateObject(String)
method cached a value before to try that method.
- Overrides:
createDatum
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the datum for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createGeodeticDatum
Returns a datum defining the location and orientation of an ellipsoid that approximates the shape of the earth. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createGeodeticDatum(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createGeodeticDatum(String)
method in the parent class. This allows to check if the more genericcreateDatum(String)
method cached a value before to try that method.
- Overrides:
createGeodeticDatum
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the datum for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createVerticalDatum
Returns a datum identifying a particular reference level surface used as a zero-height surface. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createVerticalDatum(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createVerticalDatum(String)
method in the parent class. This allows to check if the more genericcreateDatum(String)
method cached a value before to try that method.
- Overrides:
createVerticalDatum
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the datum for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createTemporalDatum
Returns a datum defining the origin of a temporal coordinate reference system. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createTemporalDatum(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createTemporalDatum(String)
method in the parent class. This allows to check if the more genericcreateDatum(String)
method cached a value before to try that method.
- Overrides:
createTemporalDatum
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the datum for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createEngineeringDatum
Returns a datum defining the origin of an engineering coordinate reference system. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createEngineeringDatum(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createEngineeringDatum(String)
method in the parent class. This allows to check if the more genericcreateDatum(String)
method cached a value before to try that method.
- Overrides:
createEngineeringDatum
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the datum for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createImageDatum
Returns a datum defining the origin of an image coordinate reference system. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createImageDatum(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createImageDatum(String)
method in the parent class. This allows to check if the more genericcreateDatum(String)
method cached a value before to try that method.
- Overrides:
createImageDatum
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the datum for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createEllipsoid
Returns a geometric figure that can be used to describe the approximate shape of the earth. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createEllipsoid(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createEllipsoid(String)
method in the parent class. This allows to check if the more genericcreateObject(String)
method cached a value before to try that method.
- Overrides:
createEllipsoid
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the ellipsoid for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createPrimeMeridian
Returns a prime meridian defining the origin from which longitude values are determined. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createPrimeMeridian(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createPrimeMeridian(String)
method in the parent class. This allows to check if the more genericcreateObject(String)
method cached a value before to try that method.
- Overrides:
createPrimeMeridian
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the prime meridian for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createExtent
Returns information about spatial, vertical, and temporal extent (usually a domain of validity) from a code. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createExtent(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createExtent(String)
method in the parent class.
- Overrides:
createExtent
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the extent for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createCoordinateSystem
Returns an arbitrary coordinate system from a code. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createCoordinateSystem(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createCoordinateSystem(String)
method in the parent class. This allows to check if the more genericcreateObject(String)
method cached a value before to try that method.
- Overrides:
createCoordinateSystem
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createEllipsoidalCS
Returns a 2- or 3-dimensional coordinate system for geodetic latitude and longitude, sometimes with ellipsoidal height. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createEllipsoidalCS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createEllipsoidalCS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateSystem(String)
method cached a value before to try that method.
- Overrides:
createEllipsoidalCS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createVerticalCS
Returns a 1-dimensional coordinate system for heights or depths of points. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createVerticalCS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createVerticalCS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateSystem(String)
method cached a value before to try that method.
- Overrides:
createVerticalCS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createTimeCS
Returns a 1-dimensional coordinate system for heights or depths of points. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createTimeCS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createTimeCS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateSystem(String)
method cached a value before to try that method.
- Overrides:
createTimeCS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createCartesianCS
Returns a 2- or 3-dimensional Cartesian coordinate system made of straight orthogonal axes. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createCartesianCS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createCartesianCS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateSystem(String)
method cached a value before to try that method.
- Overrides:
createCartesianCS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createSphericalCS
Returns a 3-dimensional coordinate system with one distance measured from the origin and two angular coordinates. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createSphericalCS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createSphericalCS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateSystem(String)
method cached a value before to try that method.
- Overrides:
createSphericalCS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createCylindricalCS
Returns a 3-dimensional coordinate system made of a polar coordinate system extended by a straight perpendicular axis. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createCylindricalCS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createCylindricalCS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateSystem(String)
method cached a value before to try that method.
- Overrides:
createCylindricalCS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createPolarCS
Returns a 2-dimensional coordinate system for coordinates represented by a distance from the origin and an angle from a fixed direction. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createPolarCS(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createPolarCS(String)
method in the parent class. This allows to check if the more genericcreateCoordinateSystem(String)
method cached a value before to try that method.
- Overrides:
createPolarCS
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the coordinate system for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createCoordinateSystemAxis
Returns a coordinate system axis with name, direction, unit and range of values. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createCoordinateSystemAxis(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createCoordinateSystemAxis(String)
method in the parent class. This allows to check if the more genericcreateObject(String)
method cached a value before to try that method.
- Overrides:
createCoordinateSystemAxis
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the axis for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createUnit
Returns an unit of measurement from a code. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createUnit(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createUnit(String)
method in the parent class.
- Overrides:
createUnit
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the unit of measurement for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createParameterDescriptor
Returns a definition of a single parameter used by an operation method. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createParameterDescriptor(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createParameterDescriptor(String)
method in the parent class. This allows to check if the more genericcreateObject(String)
method cached a value before to try that method.
- Overrides:
createParameterDescriptor
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the parameter descriptor for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createOperationMethod
Returns a description of the algorithm and parameters used to perform a coordinate operation. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createOperationMethod(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createOperationMethod(String)
method in the parent class. This allows to check if the more genericcreateObject(String)
method cached a value before to try that method.
- Overrides:
createOperationMethod
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the operation method for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createCoordinateOperation
Returns an operation for transforming coordinates in the source CRS to coordinates in the target CRS. The default implementation performs the following steps:- Return the cached instance for the given code if such instance already exists.
- Otherwise if the Data Access Object (DAO) overrides the
createCoordinateOperation(String)
method, invoke that method and cache the result for future use. - Otherwise delegate to the
GeodeticAuthorityFactory.createCoordinateOperation(String)
method in the parent class. This allows to check if the more genericcreateObject(String)
method cached a value before to try that method.
- Overrides:
createCoordinateOperation
in classGeodeticAuthorityFactory
- Parameters:
code
- value allocated by authority.- Returns:
- the operation for the given code.
- Throws:
FactoryException
- if the object creation failed.- See Also:
-
createFromCoordinateReferenceSystemCodes
public Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes(String sourceCRS, String targetCRS) throws FactoryException Returns operations from source and target coordinate reference system codes. The default implementation performs the following steps:- Returns the cached collection for the given pair of codes if such collection already exists.
- Otherwise:
- get an instance of the Data Access Object,
- delegate to its
GeodeticAuthorityFactory.createFromCoordinateReferenceSystemCodes(String, String)
method, - release the Data Access Object — this step assumes that the collection obtained at step 2 is still valid after the Data Access Object has been released,
- cache the result — this step assumes that the collection obtained at step 2 is immutable.
- Overrides:
createFromCoordinateReferenceSystemCodes
in classGeodeticAuthorityFactory
- Parameters:
sourceCRS
- coded value of source coordinate reference system.targetCRS
- coded value of target coordinate reference system.- Returns:
- the operations from
sourceCRS
totargetCRS
. - Throws:
FactoryException
- if the object creation failed.
-
newIdentifiedObjectFinder
Returns a finder which can be used for looking up unidentified objects. The default implementation delegates lookup to the underlying Data Access Object and caches the result.- Overrides:
newIdentifiedObjectFinder
in classGeodeticAuthorityFactory
- Returns:
- a finder to use for looking up unidentified objects.
- Throws:
FactoryException
- if the finder cannot be created.- See Also:
-
isCacheable
Returns whether the given object can be cached. This method is invoked after the Data Access Object created a new object not previously in the cache. If thisisCacheable(…)
method returnstrue
, then the newly created object will be cached so that next calls to the samecreateFoo(String)
method with the same code may return the same object. If this method returnsfalse
, then the newly created object will not be cached and next call to thecreateFoo(String)
method with the same code will return a new object.The default implementation always returns
true
. Subclasses can override this method for filtering the objects to store in the cache.- Parameters:
code
- the authority code specified by the caller for creating an object.object
- the object created for the given authority code.- Returns:
- whether the given object should be cached.
- Since:
- 0.8
- See Also:
-
printCacheContent
Prints the cache content to the given writer. Keys are sorted by numerical order if possible, or alphabetical order otherwise. This method is used for debugging purpose only.- Parameters:
out
- the output printer, ornull
for the standard output stream.- See Also:
-
close
Immediately closes all Data Access Objects that are closeable. This method does not clear the cache and does not disallow further usage of this factory: thisConcurrentAuthorityFactory
can still be used as usual after it has been "closed". New Data Access Objects will be created if needed for replacing the ones closed by this method.The main purpose of this method is to force immediate release of JDBC connections or other kind of resources that Data Access Objects may hold. If this method is not invoked, Data Access Objects will be closed when this
ConcurrentAuthorityFactory
will be garbage collected or at JVM shutdown time, depending which event happen first.- Specified by:
close
in interfaceAutoCloseable
- Throws:
FactoryException
- if an error occurred while closing the Data Access Objects.- See Also:
-
toString
Returns a string representation of this factory for debugging purpose only. The string returned by this method may change in any future SIS version.- Overrides:
toString
in classGeodeticAuthorityFactory
- Returns:
- a string representation for debugging purpose.
- See Also:
-