Because Geotools core API consists almost exclusively of interfaces, factories play a role in how developers use the API. Although the interfaces are implemented in various GeoTools packages you should not use those classes directly. Instead you should use factories.
FactoryRegistry provides a general to instantiate and
manage factories (also called service providers). Each factory implementation is found
using ServiceLocator (declaired in
module-info.java or in
jar META-INF/services directory.
DatumFactoryimplementations, then it must provide the following file:
with a content similar to the one below:
com.mycompany.MyDatumFactory1 com.mycompany.MyDatumFactory2 com.mycompany.MyDatumFactory3
The ordering is initially unspecified. Users can
set an ordering
explicitly themselves, or implementations can do that automatically
org.geotools.factory.AbstractFactory class provides a simple way to setup ordering
on registration on the basis of a priority
If a user wants a specific implementation, he can
iterates through registered ones
and pickup the desired implementation himself. An alternative is to bundle the criterions in a
map of hints and lets the registry selects an implementation
accordingly. This later functionality is not provided by the standard
but is provided by Geotools's
org.geotools.factory.FactoryRegistry extension. This class extends
the service registry API with the following functionalities:
scanForPlugins()method that scans for plugins in the registry class loader, the thread context class loader and the system class loader. Additionally,
scanForPlugins()looks for any implementation specified as system property.
Filters out automatically optional factories when they are not available.
When more than one implementation is available for the same
org.geotools.factory.Factorysubinterface, an optional set of hints can specifies the criterions that the desired implementation must meets. If a factory implementation depends on other factories, the dependencies hints are checked recursively.
Optionally, if no factory matches the given hints, a new instance can be automatically created.
Note that the hints, if provided, don't need to apply
directly to the requested factory category. They may apply indirectly through some dependency. A typical example is
a request for any
GeometryFactory instance, providing that this instance uses a
Interface Summary Interface Description BufferedFactoryA marker interface for factories that are buffering their objects in some way. FactoryBase interface for Geotools factories (i.e. service discovery). FactoryIteratorProviderProvides iterators over factories of specified categories. OptionalFactoryAn optional factory that may not be available in all configurations. RegistrableFactory
Class Summary Class Description AbstractFactorySkeletal implementation of factories. FactoryCreatorA factory registry capable to creates factories if no appropriate instance was found in the registry. FactoryFinderBase class for factory finders. FactoryRegistryA registry for factories, organized by categories (usually by interface). GeoToolsStatic methods relative to the global GeoTools configuration. HintsA set of hints providing control on factories to be used. Hints.ClassKeyA key for value that may be specified either as instance of
T, or as
Hints.ConfigurationMetadataKeyKeys for extra configuration options that are passed from the overhead application into queries. Hints.DoubleKeyA hint used to capture a configuration setting as double. Hints.FileKeyKey for hints to be specified as a
Hints.IntegerKeyA hint used to capture a configuration setting as an integer. Hints.KeyThe type for keys used to control various aspects of the factory creation. Hints.OptionKeyKey that allows the choice of several options.
Exception Summary Exception Description FactoryNotFoundExceptionThrown when a factory can't be found in the registery. FactoryRegistryExceptionThrown when a factory can't be found or can't be instantiate. RecursiveSearchExceptionThrown when
FactoryRegistryis invoked recursively for the same category.