org.geotools.referencing.factory
Class AbstractAuthorityMediator

Object
  extended by AbstractFactory
      extended by ReferencingFactory
          extended by AbstractAuthorityFactory
              extended by AbstractAuthorityMediator
All Implemented Interfaces:
RegisterableService, BufferedFactory, Factory, AuthorityFactory, CRSAuthorityFactory, CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory
Direct Known Subclasses:
AbstractEpsgMediator

public abstract class AbstractAuthorityMediator
extends AbstractAuthorityFactory
implements AuthorityFactory, CRSAuthorityFactory, CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, BufferedFactory

An authority mediator that consults (a possibily shared) cache before delegating the generation of the content to a "worker" authority factory.

The behaviour of the 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:

Since:
2.4
Author:
Jody Garnett (Refractions Research), Cory Horner (Refractions Research)
Module:
trunk/gt/modules   (gt-modules.jar) (Maven report) (SVN head)

Nested Class Summary
protected  class AbstractAuthorityMediator.WorkerSafeRunnable
          An interface describing a portion of work for which a worker is needed.
 
Field Summary
protected  ReferencingFactoryContainer factories
          A container of the "real factories" actually used to construct objects.
 
Fields inherited from class ReferencingFactory
LOGGER
 
Fields inherited from class AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
 
Constructor Summary
protected AbstractAuthorityMediator()
          Constructs an instance making use of the default cache and priority level.
protected AbstractAuthorityMediator(Hints hints)
          Constructs an instance based on the provided Hints
protected AbstractAuthorityMediator(int priority)
          Constructs an instance making use of the default cache.
protected AbstractAuthorityMediator(int priority, Hints hints)
          Constructs an instance making use of the default cache.
protected AbstractAuthorityMediator(int priority, ObjectCache cache, ReferencingFactoryContainer container)
          Constructs an instance making use of the indicated cache.
 
Method Summary
protected abstract  void activateWorker(AbstractCachedAuthorityFactory worker)
          Reinitialize an instance to be returned by the pool.
protected  void completeHints()
           
 CartesianCS createCartesianCS(String code)
          Creates a cartesian coordinate system from a code.
 CompoundCRS createCompoundCRS(String code)
          Creates a 3D coordinate reference system from a code.
 CoordinateOperation createCoordinateOperation(String code)
          Creates an operation from a single operation code.
 CoordinateReferenceSystem createCoordinateReferenceSystem(String code)
          Returns an arbitrary coordinate reference system from a code.
 CoordinateSystem createCoordinateSystem(String code)
          Returns an arbitrary coordinate system from a code.
 CoordinateSystemAxis createCoordinateSystemAxis(String code)
          Returns a coordinate system axis from a code.
 CylindricalCS createCylindricalCS(String code)
          Creates a cylindrical coordinate system from a code.
 Datum createDatum(String code)
          Returns an arbitrary datum from a code.
 DerivedCRS createDerivedCRS(String code)
          Creates a derived coordinate reference system from a code.
 Ellipsoid createEllipsoid(String code)
          Returns an ellipsoid from a code.
 EllipsoidalCS createEllipsoidalCS(String code)
          Creates an ellipsoidal coordinate system from a code.
 EngineeringDatum createEngineeringDatum(String code)
          Creates a engineering datum from a code.
 Set createFromCoordinateReferenceSystemCodes(String sourceCode, String targetCode)
          Creates an operation from coordinate reference system codes.
 GeocentricCRS createGeocentricCRS(String code)
          Returns a geocentric coordinate reference system from a code.
 GeodeticDatum createGeodeticDatum(String code)
          Returns a geodetic datum from a code.
 GeographicCRS createGeographicCRS(String code)
          Returns a geographic coordinate reference system from a code.
 ImageCRS createImageCRS(String code)
          Creates a image coordinate reference system from a code.
 ImageDatum createImageDatum(String code)
          Creates a image datum from a code.
 IdentifiedObject createObject(String code)
          Returns an arbitrary object from a code.
 PolarCS createPolarCS(String code)
          Creates a polar coordinate system from a code.
 PrimeMeridian createPrimeMeridian(String code)
          Returns a prime meridian from a code.
 ProjectedCRS createProjectedCRS(String code)
          Returns a projected coordinate reference system from a code.
 SphericalCS createSphericalCS(String code)
          Creates a spherical coordinate system from a code.
 TemporalCRS createTemporalCRS(String code)
          Creates a temporal coordinate reference system from a code.
 TemporalDatum createTemporalDatum(String code)
          Creates a temporal datum from a code.
 TimeCS createTimeCS(String code)
          Creates a temporal coordinate system from a code.
 Unit<?> createUnit(String code)
          Returns an unit from a code.
 VerticalCRS createVerticalCRS(String code)
          Creates a vertical coordinate reference system from a code.
 VerticalCS createVerticalCS(String code)
          Creates a vertical coordinate system from a code.
 VerticalDatum createVerticalDatum(String code)
          Creates a vertical datum from a code.
protected
<T> T
createWith(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  void destroyWorker(AbstractCachedAuthorityFactory worker)
          Destroys an instance no longer needed by the pool.
 void dispose()
          Clean up the object pool of workers (since we are shutting down).
abstract  Citation getAuthority()
          The authority body of the objects this factory provides.
 Set getAuthorityCodes(Class type)
           
 String getBackingStoreDescription()
          Returns a description of the underlying backing store, or null if unknown.
abstract  InternationalString getDescriptionText(String code)
           
 IdentifiedObjectFinder getIdentifiedObjectFinder(Class type)
          Returns a finder which can be used for looking up unidentified objects.
 boolean isConnected()
          True if this mediator is currently connected to one or more workers.
protected abstract  AbstractCachedAuthorityFactory makeWorker()
          Creates an instance that can be returned by the pool.
protected abstract  void passivateWorker(AbstractCachedAuthorityFactory worker)
          Un-initialize an instance to be returned to the pool.
protected  String toKey(String code)
           
protected  String trimAuthority(String code)
          Trims the authority scope, if present.
protected abstract  boolean validateWorker(AbstractCachedAuthorityFactory worker)
          Ensures that the instance is safe to be returned by the pool.
 
Methods inherited from class AbstractAuthorityFactory
createEngineeringCRS, createExtent, createOperationMethod, createParameterDescriptor, noSuchAuthorityCode
 
Methods inherited from class ReferencingFactory
ensureNonNull, getVendor
 
Methods inherited from class AbstractFactory
addImplementationHints, equals, getImplementationHints, getPriority, hashCode, onDeregistration, onRegistration, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Factory
getVendor
 
Methods inherited from interface CRSAuthorityFactory
createEngineeringCRS
 
Methods inherited from interface Factory
getVendor
 
Methods inherited from interface Factory
getVendor
 
Methods inherited from interface Factory
getVendor
 
Methods inherited from interface Factory
getVendor
 
Methods inherited from interface Factory
getImplementationHints
 

Field Detail

factories

protected final ReferencingFactoryContainer factories
A container of the "real factories" actually used to construct objects.

Constructor Detail

AbstractAuthorityMediator

protected AbstractAuthorityMediator()
Constructs an instance making use of the default cache and priority level.


AbstractAuthorityMediator

protected AbstractAuthorityMediator(Hints hints)
Constructs an instance based on the provided Hints

Parameters:
factory - The factory to cache. Can not be null.

AbstractAuthorityMediator

protected AbstractAuthorityMediator(int priority)
Constructs an instance making use of the default cache.

Parameters:
factory - The factory to cache. Can not be null.

AbstractAuthorityMediator

protected AbstractAuthorityMediator(int priority,
                                    Hints hints)
Constructs an instance making use of the default cache.

Parameters:
factory - The factory to cache. Can not be null.

AbstractAuthorityMediator

protected AbstractAuthorityMediator(int priority,
                                    ObjectCache 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, CRSAuthorityFactory and CoordinateOperationAuthorityFactory interfaces they choose to implement.

Parameters:
factory - The factory to cache. Can not be null.
maxStrongReferences - The maximum number of objects to keep by strong reference.
Method Detail

completeHints

protected void completeHints()

isConnected

public boolean isConnected()
True if this mediator is currently connected to one or more workers.

Returns:

toKey

protected String toKey(String code)

trimAuthority

protected String trimAuthority(String code)
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:
trimAuthority in class AbstractAuthorityFactory
Parameters:
code - The code to trim.
Returns:
The code without the authority scope.

getAuthority

public abstract Citation getAuthority()
The authority body of the objects this factory provides.

Specified by:
getAuthority in interface AuthorityFactory
Specified by:
getAuthority in class AbstractAuthorityFactory

getAuthorityCodes

public Set getAuthorityCodes(Class type)
                      throws FactoryException
Specified by:
getAuthorityCodes in interface AuthorityFactory
Throws:
FactoryException

getDescriptionText

public abstract InternationalString getDescriptionText(String code)
                                                throws FactoryException
Specified by:
getDescriptionText in interface AuthorityFactory
Throws:
FactoryException

createObject

public IdentifiedObject createObject(String code)
                              throws FactoryException
Description copied from class: AbstractAuthorityFactory
Returns an arbitrary object from a code. The returned object will typically be an instance of Datum, CoordinateSystem, CoordinateReferenceSystem or CoordinateOperation. 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:
createObject in interface AuthorityFactory
Overrides:
createObject in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createCoordinateReferenceSystem(java.lang.String), AbstractAuthorityFactory.createDatum(java.lang.String), AbstractAuthorityFactory.createEllipsoid(java.lang.String), AbstractAuthorityFactory.createUnit(java.lang.String)

createCompoundCRS

public CompoundCRS createCompoundCRS(String code)
                              throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a 3D coordinate reference system from a code.

Specified by:
createCompoundCRS in interface CRSAuthorityFactory
Overrides:
createCompoundCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createCoordinateReferenceSystem

public CoordinateReferenceSystem createCoordinateReferenceSystem(String code)
                                                          throws FactoryException
Description copied from class: AbstractAuthorityFactory
Returns 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 example  createGeographicCRS(code)  instead of  createCoordinateReferenceSystem(code)  if the caller know he is asking for a geographic coordinate reference system).

Specified by:
createCoordinateReferenceSystem in interface CRSAuthorityFactory
Overrides:
createCoordinateReferenceSystem in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was 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

public DerivedCRS createDerivedCRS(String code)
                            throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a derived coordinate reference system from a code.

Specified by:
createDerivedCRS in interface CRSAuthorityFactory
Overrides:
createDerivedCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createGeocentricCRS

public GeocentricCRS createGeocentricCRS(String code)
                                  throws FactoryException
Description copied from class: AbstractAuthorityFactory
Returns a geocentric coordinate reference system from a code.

Specified by:
createGeocentricCRS in interface CRSAuthorityFactory
Overrides:
createGeocentricCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed.
See Also:
AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)

createGeographicCRS

public GeographicCRS createGeographicCRS(String code)
                                  throws FactoryException
Description copied from class: AbstractAuthorityFactory
Returns a geographic coordinate reference system from a code.

Specified by:
createGeographicCRS in interface CRSAuthorityFactory
Overrides:
createGeographicCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)

createImageCRS

public ImageCRS createImageCRS(String code)
                        throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a image coordinate reference system from a code.

Specified by:
createImageCRS in interface CRSAuthorityFactory
Overrides:
createImageCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createProjectedCRS

public ProjectedCRS createProjectedCRS(String code)
                                throws FactoryException
Description copied from class: AbstractAuthorityFactory
Returns a projected coordinate reference system from a code.

Specified by:
createProjectedCRS in interface CRSAuthorityFactory
Overrides:
createProjectedCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)

createTemporalCRS

public TemporalCRS createTemporalCRS(String code)
                              throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a temporal coordinate reference system from a code.

Specified by:
createTemporalCRS in interface CRSAuthorityFactory
Overrides:
createTemporalCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createTemporalDatum(java.lang.String)

createVerticalCRS

public VerticalCRS createVerticalCRS(String code)
                              throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a vertical coordinate reference system from a code.

Specified by:
createVerticalCRS in interface CRSAuthorityFactory
Overrides:
createVerticalCRS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate reference system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createVerticalDatum(java.lang.String)

createCartesianCS

public CartesianCS createCartesianCS(String code)
                              throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a cartesian coordinate system from a code. The default implementation invokes createCoordinateSystem(code).

Specified by:
createCartesianCS in interface CSAuthorityFactory
Overrides:
createCartesianCS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createCoordinateSystem

public CoordinateSystem createCoordinateSystem(String code)
                                        throws FactoryException
Description copied from class: AbstractAuthorityFactory
Returns an arbitrary coordinate system from a code. The default implementation invokes createObject(code).

Specified by:
createCoordinateSystem in interface CSAuthorityFactory
Overrides:
createCoordinateSystem in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createCoordinateSystemAxis

public CoordinateSystemAxis createCoordinateSystemAxis(String code)
                                                throws FactoryException
Description copied from class: AbstractAuthorityFactory
Returns a coordinate system axis from a code. The default implementation invokes createObject(code).

Specified by:
createCoordinateSystemAxis in interface CSAuthorityFactory
Overrides:
createCoordinateSystemAxis in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The axis for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createCylindricalCS

public CylindricalCS createCylindricalCS(String code)
                                  throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a cylindrical coordinate system from a code. The default implementation invokes createCoordinateSystem(code).

Specified by:
createCylindricalCS in interface CSAuthorityFactory
Overrides:
createCylindricalCS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createEllipsoidalCS

public EllipsoidalCS createEllipsoidalCS(String code)
                                  throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates an ellipsoidal coordinate system from a code. The default implementation invokes createCoordinateSystem(code).

Specified by:
createEllipsoidalCS in interface CSAuthorityFactory
Overrides:
createEllipsoidalCS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createPolarCS

public PolarCS createPolarCS(String code)
                      throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a polar coordinate system from a code. The default implementation invokes createCoordinateSystem(code).

Specified by:
createPolarCS in interface CSAuthorityFactory
Overrides:
createPolarCS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createSphericalCS

public SphericalCS createSphericalCS(String code)
                              throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a spherical coordinate system from a code. The default implementation invokes createCoordinateSystem(code).

Specified by:
createSphericalCS in interface CSAuthorityFactory
Overrides:
createSphericalCS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createTimeCS

public TimeCS createTimeCS(String code)
                    throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a temporal coordinate system from a code. The default implementation invokes createCoordinateSystem(code).

Specified by:
createTimeCS in interface CSAuthorityFactory
Overrides:
createTimeCS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createUnit

public Unit<?> createUnit(String code)
                   throws FactoryException
Description copied from class: AbstractAuthorityFactory
Returns an unit from a code. The default implementation invokes createObject(code).

Specified by:
createUnit in interface CSAuthorityFactory
Overrides:
createUnit in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The unit for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createVerticalCS

public VerticalCS createVerticalCS(String code)
                            throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a vertical coordinate system from a code. The default implementation invokes createCoordinateSystem(code).

Specified by:
createVerticalCS in interface CSAuthorityFactory
Overrides:
createVerticalCS in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createDatum

public Datum createDatum(String code)
                  throws FactoryException
Description copied from class: AbstractAuthorityFactory
Returns an arbitrary datum from a code. The default implementation invokes createObject(code).

Specified by:
createDatum in interface DatumAuthorityFactory
Overrides:
createDatum in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The datum for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createGeodeticDatum(java.lang.String), AbstractAuthorityFactory.createVerticalDatum(java.lang.String), AbstractAuthorityFactory.createTemporalDatum(java.lang.String)

createEllipsoid

public Ellipsoid createEllipsoid(String code)
                          throws FactoryException
Description copied from class: AbstractAuthorityFactory
Returns an ellipsoid from a code. The default implementation invokes createObject(code).

Specified by:
createEllipsoid in interface DatumAuthorityFactory
Overrides:
createEllipsoid in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The ellipsoid for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)

createEngineeringDatum

public EngineeringDatum createEngineeringDatum(String code)
                                        throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a engineering datum from a code. The default implementation invokes createDatum(code).

Specified by:
createEngineeringDatum in interface DatumAuthorityFactory
Overrides:
createEngineeringDatum in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The datum for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createEngineeringCRS(java.lang.String)

createGeodeticDatum

public GeodeticDatum createGeodeticDatum(String code)
                                  throws FactoryException
Description copied from class: AbstractAuthorityFactory
Returns a geodetic datum from a code. The default implementation invokes createDatum(code).

Specified by:
createGeodeticDatum in interface DatumAuthorityFactory
Overrides:
createGeodeticDatum in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The datum for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createEllipsoid(java.lang.String), AbstractAuthorityFactory.createPrimeMeridian(java.lang.String), AbstractAuthorityFactory.createGeographicCRS(java.lang.String), AbstractAuthorityFactory.createProjectedCRS(java.lang.String)

createImageDatum

public ImageDatum createImageDatum(String code)
                            throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a image datum from a code. The default implementation invokes createDatum(code).

Specified by:
createImageDatum in interface DatumAuthorityFactory
Overrides:
createImageDatum in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The datum for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createImageCRS(java.lang.String)

createPrimeMeridian

public PrimeMeridian createPrimeMeridian(String code)
                                  throws FactoryException
Description copied from class: AbstractAuthorityFactory
Returns a prime meridian from a code. The default implementation invokes createObject(code).

Specified by:
createPrimeMeridian in interface DatumAuthorityFactory
Overrides:
createPrimeMeridian in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The prime meridian for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createGeodeticDatum(java.lang.String)

createTemporalDatum

public TemporalDatum createTemporalDatum(String code)
                                  throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a temporal datum from a code. The default implementation invokes createDatum(code).

Specified by:
createTemporalDatum in interface DatumAuthorityFactory
Overrides:
createTemporalDatum in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The datum for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createTemporalCRS(java.lang.String)

createVerticalDatum

public VerticalDatum createVerticalDatum(String code)
                                  throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates a vertical datum from a code. The default implementation invokes createDatum(code).

Specified by:
createVerticalDatum in interface DatumAuthorityFactory
Overrides:
createVerticalDatum in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The datum for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.
See Also:
AbstractAuthorityFactory.createVerticalCRS(java.lang.String)

createCoordinateOperation

public CoordinateOperation createCoordinateOperation(String code)
                                              throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates an operation from a single operation code.

Specified by:
createCoordinateOperation in interface CoordinateOperationAuthorityFactory
Overrides:
createCoordinateOperation in class AbstractAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The operation for the given code.
Throws:
NoSuchAuthorityCodeException - if the specified code was not found.
FactoryException - if the object creation failed for some other reason.

createFromCoordinateReferenceSystemCodes

public Set createFromCoordinateReferenceSystemCodes(String sourceCode,
                                                    String targetCode)
                                             throws FactoryException
Description copied from class: AbstractAuthorityFactory
Creates an operation from coordinate reference system codes. The default implementation returns an 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:
createFromCoordinateReferenceSystemCodes in interface CoordinateOperationAuthorityFactory
Overrides:
createFromCoordinateReferenceSystemCodes in class AbstractAuthorityFactory
Parameters:
sourceCode - Coded value of source coordinate reference system.
targetCode - Coded value of target coordinate reference system.
Returns:
The operations from sourceCRS to targetCRS.
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:


  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);
      }
  }
 
And worker management when generating values:

 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 cache
runner - Used to generate a value in the case of a cache miss
Returns:
value from either the cache or generated
Throws:
FactoryException

getBackingStoreDescription

public String getBackingStoreDescription()
                                  throws FactoryException
Description copied from class: AbstractAuthorityFactory
Returns a description of the underlying backing store, or null if unknown. This is for example the database software used for storing the data. The default implementation returns always null.

Overrides:
getBackingStoreDescription in class AbstractAuthorityFactory
Returns:
The description of the underlying backing store, or null.
Throws:
FactoryException - if a failure occurs while fetching the engine description.

dispose

public void dispose()
             throws FactoryException
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:
dispose in class AbstractAuthorityFactory
Throws:
FactoryException - if an error occured while disposing the factory.

activateWorker

protected abstract void activateWorker(AbstractCachedAuthorityFactory worker)
                                throws Exception
Reinitialize an instance to be returned by the pool.

Please note that BEFORE this method has been called AbstractAuthorityMediator has already:

Throws:
Exception

destroyWorker

protected abstract void destroyWorker(AbstractCachedAuthorityFactory worker)
                               throws Exception
Destroys an instance no longer needed by the pool.

Throws:
Exception

makeWorker

protected abstract AbstractCachedAuthorityFactory makeWorker()
                                                      throws Exception
Creates an instance that can be returned by the pool.

Throws:
Exception

passivateWorker

protected abstract void passivateWorker(AbstractCachedAuthorityFactory worker)
                                 throws Exception
Un-initialize an instance to be returned to the pool.

Throws:
Exception

validateWorker

protected abstract boolean validateWorker(AbstractCachedAuthorityFactory worker)
Ensures that the instance is safe to be returned by the pool.


getIdentifiedObjectFinder

public IdentifiedObjectFinder getIdentifiedObjectFinder(Class 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:
getIdentifiedObjectFinder in class AbstractAuthorityFactory
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


Copyright © 1996-2009 Geotools. All Rights Reserved.