Skip navigation links

Package org.geotools.util.factory

Utility classes which enable dynamic binding to factory implementations at runtime.

See: Description

Package org.geotools.util.factory Description

Utility classes which enable dynamic binding to factory implementations at runtime.

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.

GeoTools 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.

For example if a JAR file provides one or more DatumFactory implementations, then it must provide the following file:

META-INF/services/org.opengis.referencing.datum.DatumFactory

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 on registration. The org.geotools.factory.AbstractFactory class provides a simple way to setup ordering on registration on the basis of a priority number.

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 ServiceRegistry, but is provided by Geotools's org.geotools.factory.FactoryRegistry extension. This class extends the service registry API with the following functionalities:

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 particular CoordinateSequenceFactory implementation.

Skip navigation links

Copyright © 1996–2020 Geotools. All rights reserved.