org.geotools.referencing.factory
Class DeferredAuthorityFactory

java.lang.Object
  extended byorg.geotools.factory.AbstractFactory
      extended byorg.geotools.referencing.factory.AbstractFactory
          extended byorg.geotools.referencing.factory.AbstractAuthorityFactory
              extended byorg.geotools.referencing.factory.BufferedAuthorityFactory
                  extended byorg.geotools.referencing.factory.DeferredAuthorityFactory
All Implemented Interfaces:
org.opengis.referencing.AuthorityFactory, org.opengis.referencing.operation.CoordinateOperationAuthorityFactory, org.opengis.referencing.crs.CRSAuthorityFactory, org.opengis.referencing.cs.CSAuthorityFactory, org.opengis.referencing.datum.DatumAuthorityFactory, Factory, org.opengis.referencing.Factory, OptionalFactory, javax.imageio.spi.RegisterableService
Direct Known Subclasses:
DefaultFactory, FactoryUsingWKT

public abstract class DeferredAuthorityFactory
extends BufferedAuthorityFactory
implements OptionalFactory

A buffered authority factory which will defer the creation of a backing store until when first needed. This approach allow to etablish a connection to a database (for example) only when first needed. In addition, the backing store can be automatically disposed after a timeout and recreated when needed again.

Since:
2.1
Version:
$Id: DeferredAuthorityFactory.java 18103 2006-02-20 10:42:52Z desruisseaux $
Author:
Martin Desruisseaux

Field Summary
 
Fields inherited from class org.geotools.referencing.factory.AbstractAuthorityFactory
factories
 
Fields inherited from class org.geotools.referencing.factory.AbstractFactory
LOGGER
 
Fields inherited from class org.geotools.factory.AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
 
Constructor Summary
protected DeferredAuthorityFactory(FactoryGroup factories, int priority)
          Deprecated. Use DeferredAuthorityFactory(Hints,int) instead.
protected DeferredAuthorityFactory(FactoryGroup factories, int priority, int maxStrongReferences)
          Deprecated. Use DeferredAuthorityFactory(Hints,int,int) instead.
protected DeferredAuthorityFactory(Hints hints, int priority)
          Constructs an instance without initial backing store.
protected DeferredAuthorityFactory(Hints hints, int priority, int maxStrongReferences)
          Constructs an instance without initial backing store.
 
Method Summary
protected  boolean canDisposeBackingStore(AbstractAuthorityFactory backingStore)
          Returns if the backing store can be disposed now.
protected abstract  AbstractAuthorityFactory createBackingStore()
          Creates the backing store authority factory.
 void dispose()
          Releases resources immediately instead of waiting for the garbage collector.
 boolean isConnected()
          Returns if this deferred factory is connected to its backing store.
 boolean isReady()
          Returns if this factory is ready.
 void setTimeout(long delay)
          Set a timer for disposing the backing store after the specified amount of milliseconds of inactivity.
 
Methods inherited from class org.geotools.referencing.factory.BufferedAuthorityFactory
createCartesianCS, createCompoundCRS, createCoordinateOperation, createCoordinateReferenceSystem, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createDatum, createDerivedCRS, createEllipsoid, createEllipsoidalCS, createEngineeringCRS, createEngineeringDatum, createExtent, createFromCoordinateReferenceSystemCodes, createGeocentricCRS, createGeodeticDatum, createGeographicCRS, createImageCRS, createImageDatum, createObject, createOperationMethod, createParameterDescriptor, createPolarCS, createPrimeMeridian, createProjectedCRS, createSphericalCS, createTemporalCRS, createTemporalDatum, createTimeCS, createUnit, createVerticalCRS, createVerticalCS, createVerticalDatum, getAuthority, getAuthorityCodes, getBackingStoreDescription, getDescriptionText, getVendor
 
Methods inherited from class org.geotools.referencing.factory.AbstractAuthorityFactory
getImplementationHints, noSuchAuthorityCode, onRegistration, trimAuthority
 
Methods inherited from class org.geotools.referencing.factory.AbstractFactory
ensureNonNull
 
Methods inherited from class org.geotools.factory.AbstractFactory
onDeregistration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.geotools.factory.Factory
getImplementationHints
 

Constructor Detail

DeferredAuthorityFactory

protected DeferredAuthorityFactory(FactoryGroup factories,
                                   int priority)
Deprecated. Use DeferredAuthorityFactory(Hints,int) instead.

Constructs an instance without initial backing store. Subclasses are responsible for creating an appropriate backing store when the createBackingStore() method is invoked.

Parameters:
factories - The factories to use.
priority - The priority for this factory, as a number between MINIMUM_PRIORITY and MAXIMUM_PRIORITY inclusive.
See Also:
createBackingStore()

DeferredAuthorityFactory

protected DeferredAuthorityFactory(FactoryGroup factories,
                                   int priority,
                                   int maxStrongReferences)
Deprecated. Use DeferredAuthorityFactory(Hints,int,int) instead.

Constructs an instance without initial backing store. Subclasses are responsible for creating an appropriate backing store when the createBackingStore() method is invoked.

Parameters:
factories - The factories to use.
priority - The priority for this factory, as a number between MINIMUM_PRIORITY and MAXIMUM_PRIORITY inclusive.
maxStrongReferences - The maximum number of objects to keep by strong reference.
See Also:
createBackingStore()

DeferredAuthorityFactory

protected DeferredAuthorityFactory(Hints hints,
                                   int priority)
Constructs an instance without initial backing store. Subclasses are responsible for creating an appropriate backing store when the createBackingStore() method is invoked.

This constructor recognizes the CRS, CS, DATUM and MATH_TRANSFORM hints. In addition, the FactoryGroup.HINT_KEY hint may be used as a low-level substitute for all the above.

Parameters:
hints - The factories to use as a set of hints.
priority - The priority for this factory, as a number between MINIMUM_PRIORITY and MAXIMUM_PRIORITY inclusive.
Since:
2.2
See Also:
createBackingStore()

DeferredAuthorityFactory

protected DeferredAuthorityFactory(Hints hints,
                                   int priority,
                                   int maxStrongReferences)
Constructs an instance without initial backing store. Subclasses are responsible for creating an appropriate backing store when the createBackingStore() method is invoked.

This constructor recognizes the CRS, CS, DATUM and MATH_TRANSFORM hints. In addition, the FactoryGroup.HINT_KEY hint may be used as a low-level substitute for all the above.

Parameters:
hints - The factories to use as a set of hints.
priority - The priority for this factory, as a number between MINIMUM_PRIORITY and MAXIMUM_PRIORITY inclusive.
maxStrongReferences - The maximum number of objects to keep by strong reference.
Since:
2.2
See Also:
createBackingStore()
Method Detail

isReady

public boolean isReady()
Returns if this factory is ready. The default implementation returns if createBackingStore() throws an exception.

Specified by:
isReady in interface OptionalFactory

createBackingStore

protected abstract AbstractAuthorityFactory createBackingStore()
                                                        throws org.opengis.referencing.FactoryException
Creates the backing store authority factory. This method is invoked the first time a method is invoked.

Returns:
The backing store to uses in methods.
Throws:
FactoryNotFoundException - if the backing store has not been found.
org.opengis.referencing.FactoryException - if the creation of backing store failed for an other reason.

isConnected

public boolean isConnected()
Returns if this deferred factory is connected to its backing store. This method returns if no method has been invoked, if the backing store has been automatically disposed after the timeout or if this factoy has been disposed.


setTimeout

public void setTimeout(long delay)
Set a timer for disposing the backing store after the specified amount of milliseconds of inactivity. The createBackingStore() method will be responsible for creating a new backing store when needed. Note that the backing store disposal can be vetoed if canDisposeBackingStore(org.geotools.referencing.factory.AbstractAuthorityFactory) returns .

Parameters:
delay - The minimal delay before to close the backing store. This delay is very approximative. The backing store will not be closed before, but may take as much as twice that time before to be closed.

canDisposeBackingStore

protected boolean canDisposeBackingStore(AbstractAuthorityFactory backingStore)
Returns if the backing store can be disposed now. This method is invoked automatically after the amount of time specified by setTimeout(long) if the factory were not used during that time. The default implementation always returns . Subclasses should override this method and returns if they want to prevent the backing store disposal under some circonstances.

Parameters:
backingStore - The backing store in process of being disposed.

dispose

public void dispose()
             throws org.opengis.referencing.FactoryException
Releases resources immediately instead of waiting for the garbage collector. This method disposes the backing store regardeless of canDisposeBackingStore(org.geotools.referencing.factory.AbstractAuthorityFactory) value.

Overrides:
dispose in class BufferedAuthorityFactory
Throws:
org.opengis.referencing.FactoryException


Copyright © GeoTools. All Rights Reserved.