Class AbstractAuthorityMediator
- All Implemented Interfaces:
AuthorityFactory,CRSAuthorityFactory,CSAuthorityFactory,DatumAuthorityFactory,Factory,CoordinateOperationAuthorityFactory,BufferedFactory,Factory,RegistrableFactory
- Direct Known Subclasses:
AbstractEpsgMediator
createFoo(String) methods first looks if a previously
created object exists for the given code. If such an object exists, it is returned directly. The testing of the cache
is synchronized and may block if the referencing object is under construction.
If the object is not yet created, the definition is delegated to the appropriate createFoo method of the
factory, which will cache the result for next time.
This object is responsible for maintaining an {{ObjectCache}} of "workers" based on the following:
- Hints.AUTHORITY_MAX_ACTIVE (default 2) - indicates the maximum number of worker created, if non positive the number of workers is unbounded.
- Hints.
- Since:
- 2.4
- Author:
- Jody Garnett (Refractions Research), Cory Horner (Refractions Research)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classAn interface describing a portion of work for which a worker is needed. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ReferencingFactoryContainerA container of the "real factories" actually used to construct objects.Fields inherited from class ReferencingFactory
LOGGERFields inherited from class AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs an instance making use of the default cache and priority level.protectedAbstractAuthorityMediator(int priority) Constructs an instance making use of the default cache.protectedAbstractAuthorityMediator(int priority, Hints hints) Constructs an instance making use of the default cache.protectedAbstractAuthorityMediator(int priority, ObjectCache<Object, Object> cache, ReferencingFactoryContainer container) Constructs an instance making use of the indicated cache.protectedAbstractAuthorityMediator(Hints hints) Constructs an instance based on the provided Hints -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidReinitialize an instance to be returned by the pool.protected voidcreateCartesianCS(String code) Creates a cartesian coordinate system from a code.createCompoundCRS(String code) Creates a 3D coordinate reference system from a code.Creates an operation from a single operation code.Returns an arbitrary coordinate reference system from a code.createCoordinateSystem(String code) Returns an arbitrary coordinate system from a code.Returns a coordinate system axis from a code.createCylindricalCS(String code) Creates a cylindrical coordinate system from a code.createDatum(String code) Returns an arbitrary datum from a code.createDerivedCRS(String code) Creates a derived coordinate reference system from a code.createEllipsoid(String code) Returns an ellipsoid from a code.createEllipsoidalCS(String code) Creates an ellipsoidal coordinate system from a code.createEngineeringDatum(String code) Creates a engineering datum from a code.createFromCoordinateReferenceSystemCodes(String sourceCode, String targetCode) Creates an operation from coordinate reference system codes.createGeocentricCRS(String code) Returns a geocentric coordinate reference system from a code.createGeodeticDatum(String code) Returns a geodetic datum from a code.createGeographicCRS(String code) Returns a geographic coordinate reference system from a code.createImageCRS(String code) Creates a image coordinate reference system from a code.createImageDatum(String code) Creates a image datum from a code.createObject(String code) Returns an arbitrary object from a code.createPolarCS(String code) Creates a polar coordinate system from a code.createPrimeMeridian(String code) Returns a prime meridian from a code.createProjectedCRS(String code) Returns a projected coordinate reference system from a code.createSphericalCS(String code) Creates a spherical coordinate system from a code.createTemporalCRS(String code) Creates a temporal coordinate reference system from a code.createTemporalDatum(String code) Creates a temporal datum from a code.createTimeCS(String code) Creates a temporal coordinate system from a code.Unit<?>createUnit(String code) Returns an unit from a code.createVerticalCRS(String code) Creates a vertical coordinate reference system from a code.createVerticalCS(String code) Creates a vertical coordinate system from a code.createVerticalDatum(String code) Creates a vertical datum from a code.protected <T> TcreateWith(Object key, AbstractAuthorityMediator.WorkerSafeRunnable runner) This method is used to cut down the amount of try/catch/finally code needed when working with the cache and workers.protected abstract voidDestroys an instance no longer needed by the pool.voiddispose()Clean up the object pool of workers (since we are shutting down).abstract CitationThe authority body of the objects this factory provides.getAuthorityCodes(Class type) Returns the set of authority codes of the given type.Returns a description of the underlying backing store, ornullif unknown.abstract InternationalStringgetDescriptionText(String code) Gets a description of the object corresponding to a code.getIdentifiedObjectFinder(Class<? extends IdentifiedObject> type) Returns a finder which can be used for looking up unidentified objects.booleanTrue if this mediator is currently connected to one or more workers.protected abstract AbstractCachedAuthorityFactoryCreates an instance that can be returned by the pool.protected abstract voidUn-initialize an instance to be returned to the pool.protected Stringprotected StringtrimAuthority(String code) Trims the authority scope, if present.protected abstract booleanEnsures that the instance is safe to be returned by the pool.Methods inherited from class AbstractAuthorityFactory
createEngineeringCRS, createExtent, createOperationMethod, createParameterDescriptor, noSuchAuthorityCodeMethods inherited from class ReferencingFactory
ensureNonNull, getVendorMethods inherited from class AbstractFactory
addImplementationHints, equals, getImplementationHints, getPriority, hashCode, onDeregistration, onRegistration, toStringMethods inherited from interface CRSAuthorityFactory
createEngineeringCRSMethods inherited from interface Factory
getImplementationHints
-
Field Details
-
factories
A container of the "real factories" actually used to construct objects.
-
-
Constructor Details
-
AbstractAuthorityMediator
protected AbstractAuthorityMediator()Constructs an instance making use of the default cache and priority level. -
AbstractAuthorityMediator
Constructs an instance based on the provided Hints -
AbstractAuthorityMediator
protected AbstractAuthorityMediator(int priority) Constructs an instance making use of the default cache. -
AbstractAuthorityMediator
Constructs an instance making use of the default cache. -
AbstractAuthorityMediator
protected AbstractAuthorityMediator(int priority, ObjectCache<Object, Object> cache, ReferencingFactoryContainer container) Constructs an instance making use of the indicated cache.This constructor is protected because subclasses must declare which of the
DatumAuthorityFactory,CSAuthorityFactory,CRSAuthorityFactoryandCoordinateOperationAuthorityFactoryinterfaces they choose to implement.- Parameters:
cache- The cache to use
-
-
Method Details
-
completeHints
protected void completeHints() -
isConnected
public boolean isConnected()True if this mediator is currently connected to one or more workers. -
toKey
-
trimAuthority
Trims the authority scope, if present. For example if this factory is an EPSG authority factory and the specified code start with the "EPSG:" prefix, then the prefix is removed. Otherwise, the string is returned unchanged (except for leading and trailing spaces).- Overrides:
trimAuthorityin classAbstractAuthorityFactory- Parameters:
code- The code to trim.- Returns:
- The code without the authority scope.
-
getAuthority
The authority body of the objects this factory provides.- Specified by:
getAuthorityin interfaceAuthorityFactory- Specified by:
getAuthorityin classAbstractAuthorityFactory- Returns:
- The organization reponsible for definition of the database.
-
getAuthorityCodes
Description copied from interface:AuthorityFactoryReturns the set of authority codes of the given type. Thetypeargument specify the base class. For example if this factory is an instance ofCRSAuthorityFactory, then:CoordinateReferenceSystem.classasks for all authority codes accepted by one ofcreateGeographicCRS,createProjectedCRS,createVerticalCRS,createTemporalCRSand their friends.ProjectedCRS.classasks only for authority codes accepted bycreateProjectedCRS.
- Specified by:
getAuthorityCodesin interfaceAuthorityFactory- Parameters:
type- The spatial reference objects type.- Returns:
- The set of authority codes for spatial reference objects of the given type. If this factory doesn't contains any object of the given type, then this method returns an empty set.
- Throws:
FactoryException- if access to the underlying database failed.
-
getDescriptionText
Description copied from interface:AuthorityFactoryGets a description of the object corresponding to a code.- Specified by:
getDescriptionTextin interfaceAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- A description of the object, or
nullif the object corresponding to the specifiedcodehas no description. - Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the query failed for some other reason.
-
createObject
Description copied from class:AbstractAuthorityFactoryReturns an arbitrary object from a code. The returned object will typically be an instance ofDatum,CoordinateSystem,CoordinateReferenceSystemorCoordinateOperation. The default implementation always throw an exception. Subclasses should override this method if they are capable to automatically detect the object type from its code.- Specified by:
createObjectin interfaceAuthorityFactory- Overrides:
createObjectin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The object for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
createCompoundCRS
Description copied from class:AbstractAuthorityFactoryCreates a 3D coordinate reference system from a code.- Specified by:
createCompoundCRSin interfaceCRSAuthorityFactory- Overrides:
createCompoundCRSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createCoordinateReferenceSystem
public CoordinateReferenceSystem createCoordinateReferenceSystem(String code) throws FactoryException Description copied from class:AbstractAuthorityFactoryReturns an arbitrary coordinate reference system from a code. If the coordinate reference system type is know at compile time, it is recommended to invoke the most precise method instead of this one (for examplecreateGeographicCRS(code)instead ofcreateCoordinateReferenceSystem(code)if the caller know he is asking for a geographic coordinate reference system).- Specified by:
createCoordinateReferenceSystemin interfaceCRSAuthorityFactory- Overrides:
createCoordinateReferenceSystemin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
AbstractAuthorityFactory.createGeographicCRS(java.lang.String)AbstractAuthorityFactory.createProjectedCRS(java.lang.String)AbstractAuthorityFactory.createVerticalCRS(java.lang.String)AbstractAuthorityFactory.createTemporalCRS(java.lang.String)AbstractAuthorityFactory.createCompoundCRS(java.lang.String)
-
createDerivedCRS
Description copied from class:AbstractAuthorityFactoryCreates a derived coordinate reference system from a code.- Specified by:
createDerivedCRSin interfaceCRSAuthorityFactory- Overrides:
createDerivedCRSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createGeocentricCRS
Description copied from class:AbstractAuthorityFactoryReturns a geocentric coordinate reference system from a code.- Specified by:
createGeocentricCRSin interfaceCRSAuthorityFactory- Overrides:
createGeocentricCRSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed.- See Also:
-
createGeographicCRS
Description copied from class:AbstractAuthorityFactoryReturns a geographic coordinate reference system from a code.- Specified by:
createGeographicCRSin interfaceCRSAuthorityFactory- Overrides:
createGeographicCRSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
createImageCRS
Description copied from class:AbstractAuthorityFactoryCreates a image coordinate reference system from a code.- Specified by:
createImageCRSin interfaceCRSAuthorityFactory- Overrides:
createImageCRSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createProjectedCRS
Description copied from class:AbstractAuthorityFactoryReturns a projected coordinate reference system from a code.- Specified by:
createProjectedCRSin interfaceCRSAuthorityFactory- Overrides:
createProjectedCRSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
createTemporalCRS
Description copied from class:AbstractAuthorityFactoryCreates a temporal coordinate reference system from a code.- Specified by:
createTemporalCRSin interfaceCRSAuthorityFactory- Overrides:
createTemporalCRSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
createVerticalCRS
Description copied from class:AbstractAuthorityFactoryCreates a vertical coordinate reference system from a code.- Specified by:
createVerticalCRSin interfaceCRSAuthorityFactory- Overrides:
createVerticalCRSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate reference system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
createCartesianCS
Description copied from class:AbstractAuthorityFactoryCreates a cartesian coordinate system from a code. The default implementation invokescreateCoordinateSystem(code).- Specified by:
createCartesianCSin interfaceCSAuthorityFactory- Overrides:
createCartesianCSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createCoordinateSystem
Description copied from class:AbstractAuthorityFactoryReturns an arbitrary coordinate system from a code. The default implementation invokescreateObject(code).- Specified by:
createCoordinateSystemin interfaceCSAuthorityFactory- Overrides:
createCoordinateSystemin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createCoordinateSystemAxis
Description copied from class:AbstractAuthorityFactoryReturns a coordinate system axis from a code. The default implementation invokescreateObject(code).- Specified by:
createCoordinateSystemAxisin interfaceCSAuthorityFactory- Overrides:
createCoordinateSystemAxisin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The axis for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createCylindricalCS
Description copied from class:AbstractAuthorityFactoryCreates a cylindrical coordinate system from a code. The default implementation invokescreateCoordinateSystem(code).- Specified by:
createCylindricalCSin interfaceCSAuthorityFactory- Overrides:
createCylindricalCSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createEllipsoidalCS
Description copied from class:AbstractAuthorityFactoryCreates an ellipsoidal coordinate system from a code. The default implementation invokescreateCoordinateSystem(code).- Specified by:
createEllipsoidalCSin interfaceCSAuthorityFactory- Overrides:
createEllipsoidalCSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createPolarCS
Description copied from class:AbstractAuthorityFactoryCreates a polar coordinate system from a code. The default implementation invokescreateCoordinateSystem(code).- Specified by:
createPolarCSin interfaceCSAuthorityFactory- Overrides:
createPolarCSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createSphericalCS
Description copied from class:AbstractAuthorityFactoryCreates a spherical coordinate system from a code. The default implementation invokescreateCoordinateSystem(code).- Specified by:
createSphericalCSin interfaceCSAuthorityFactory- Overrides:
createSphericalCSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createTimeCS
Description copied from class:AbstractAuthorityFactoryCreates a temporal coordinate system from a code. The default implementation invokescreateCoordinateSystem(code).- Specified by:
createTimeCSin interfaceCSAuthorityFactory- Overrides:
createTimeCSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createUnit
Description copied from class:AbstractAuthorityFactoryReturns an unit from a code. The default implementation invokescreateObject(code).- Specified by:
createUnitin interfaceCSAuthorityFactory- Overrides:
createUnitin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The unit for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createVerticalCS
Description copied from class:AbstractAuthorityFactoryCreates a vertical coordinate system from a code. The default implementation invokescreateCoordinateSystem(code).- Specified by:
createVerticalCSin interfaceCSAuthorityFactory- Overrides:
createVerticalCSin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The coordinate system for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createDatum
Description copied from class:AbstractAuthorityFactoryReturns an arbitrary datum from a code. The default implementation invokescreateObject(code).- Specified by:
createDatumin interfaceDatumAuthorityFactory- Overrides:
createDatumin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
createEllipsoid
Description copied from class:AbstractAuthorityFactoryReturns an ellipsoid from a code. The default implementation invokescreateObject(code).- Specified by:
createEllipsoidin interfaceDatumAuthorityFactory- Overrides:
createEllipsoidin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The ellipsoid for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
createEngineeringDatum
Description copied from class:AbstractAuthorityFactoryCreates a engineering datum from a code. The default implementation invokescreateDatum(code).- Specified by:
createEngineeringDatumin interfaceDatumAuthorityFactory- Overrides:
createEngineeringDatumin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
createGeodeticDatum
Description copied from class:AbstractAuthorityFactoryReturns a geodetic datum from a code. The default implementation invokescreateDatum(code).- Specified by:
createGeodeticDatumin interfaceDatumAuthorityFactory- Overrides:
createGeodeticDatumin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
createImageDatum
Description copied from class:AbstractAuthorityFactoryCreates a image datum from a code. The default implementation invokescreateDatum(code).- Specified by:
createImageDatumin interfaceDatumAuthorityFactory- Overrides:
createImageDatumin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
createPrimeMeridian
Description copied from class:AbstractAuthorityFactoryReturns a prime meridian from a code. The default implementation invokescreateObject(code).- Specified by:
createPrimeMeridianin interfaceDatumAuthorityFactory- Overrides:
createPrimeMeridianin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The prime meridian for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
createTemporalDatum
Description copied from class:AbstractAuthorityFactoryCreates a temporal datum from a code. The default implementation invokescreateDatum(code).- Specified by:
createTemporalDatumin interfaceDatumAuthorityFactory- Overrides:
createTemporalDatumin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
createVerticalDatum
Description copied from class:AbstractAuthorityFactoryCreates a vertical datum from a code. The default implementation invokescreateDatum(code).- Specified by:
createVerticalDatumin interfaceDatumAuthorityFactory- Overrides:
createVerticalDatumin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The datum for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.- See Also:
-
createCoordinateOperation
Description copied from class:AbstractAuthorityFactoryCreates an operation from a single operation code.- Specified by:
createCoordinateOperationin interfaceCoordinateOperationAuthorityFactory- Overrides:
createCoordinateOperationin classAbstractAuthorityFactory- Parameters:
code- Value allocated by authority.- Returns:
- The operation for the given code.
- Throws:
NoSuchAuthorityCodeException- if the specifiedcodewas not found.FactoryException- if the object creation failed for some other reason.
-
createFromCoordinateReferenceSystemCodes
public Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes(String sourceCode, String targetCode) throws FactoryException Description copied from class:AbstractAuthorityFactoryCreates an operation from coordinate reference system codes. The default implementation returns an {@linkplain Collections.emptySet() empty set}. We do not delegate to some kind of coordinate operation factory method because the usual contract for this method is to extract the information from an authority database like EPSG, not to compute operations on-the-fly.Rational: Coordinate operation factory backed by an authority will invoke this method. If this method invoked the coordinate operation factory in turn, the application could be trapped in infinite recursive calls.
- Specified by:
createFromCoordinateReferenceSystemCodesin interfaceCoordinateOperationAuthorityFactory- Overrides:
createFromCoordinateReferenceSystemCodesin classAbstractAuthorityFactory- Parameters:
sourceCode- Coded value of source coordinate reference system.targetCode- Coded value of target coordinate reference system.- Returns:
- The operations from
sourceCRStotargetCRS. - Throws:
NoSuchAuthorityCodeException- if a specified code was not found.FactoryException- if the object creation failed for some other reason.
-
createWith
protected <T> T createWith(Object key, AbstractAuthorityMediator.WorkerSafeRunnable runner) throws FactoryException This method is used to cut down the amount of try/catch/finally code needed when working with the cache and workers.This code brings together two try/catch/finally blocks.
For cache management:
And worker management when generating values:T value = (T) cache.get(key); if (value == null) { try { cache.writeLock(key); value = (T) cache.peek(key); if (value == null) { ....generate value.... cache.put( key, value ); } } finally { cache.writeUnLock(key); } }AbstractCachedAuthorityFactory worker = null; try { worker = (AbstractCachedAuthorityFactory) getPool().borrowObject(); value = (T) runner.run( worker ); } catch (FactoryException e) { throw e; } catch (Exception e) { throw new FactoryException(e); } finally { try { getPool().returnObject(worker); } catch (Exception e) { LOGGER.log(Level.WARNING, "Unable to return worker " + e, e); } }- Parameters:
key- Used to look in the cacherunner- Used to generate a value in the case of a cache miss- Returns:
- value from either the cache or generated
- Throws:
FactoryException
-
getBackingStoreDescription
Description copied from class:AbstractAuthorityFactoryReturns a description of the underlying backing store, ornullif unknown. This is for example the database software used for storing the data. The default implementation returns alwaysnull.- Overrides:
getBackingStoreDescriptionin classAbstractAuthorityFactory- Returns:
- The description of the underlying backing store, or
null. - Throws:
FactoryException- if a failure occurs while fetching the engine description.
-
dispose
Clean up the object pool of workers (since we are shutting down).Subclasses may wish to override this method if they have their own resources to clean up (like a database connection). If you do this please remember to call super.dispose().
- Overrides:
disposein classAbstractAuthorityFactory- Throws:
FactoryException- if an error occured while disposing the factory.
-
activateWorker
Reinitialize an instance to be returned by the pool.Please note that BEFORE this method has been called AbstractAuthorityMediator has already:
- provided the worker with the single shared
cache - provided the worker with the single shared
findCache
- Throws:
Exception
- provided the worker with the single shared
-
destroyWorker
Destroys an instance no longer needed by the pool.- Throws:
Exception
-
makeWorker
Creates an instance that can be returned by the pool.- Throws:
Exception
-
passivateWorker
Un-initialize an instance to be returned to the pool.- Throws:
Exception
-
validateWorker
Ensures that the instance is safe to be returned by the pool. -
getIdentifiedObjectFinder
public IdentifiedObjectFinder getIdentifiedObjectFinder(Class<? extends IdentifiedObject> type) throws FactoryException Returns a finder which can be used for looking up unidentified objects.The returned implementation will make use of workers as needed.
- Overrides:
getIdentifiedObjectFinderin classAbstractAuthorityFactory- Parameters:
type- The type of objects to look for.- Returns:
- A finder to use for looking up unidentified objects.
- Throws:
FactoryException- if the finder can not be created.- Since:
- 2.4
-