/** * @deprecated Replaced with {@link #getFactory(Class, Predicate, Hints, * org.geotools.util.factory.Hints.Key)} */ @Deprecated public <T> T getServiceProvider( final Class<T> category, final ServiceRegistry.Filter filter, Hints hints, final Hints.Key key) throws FactoryRegistryException { Predicate<T> predicate = filter == null ? null : filter::filter; return getFactory(category, predicate, hints, key); }
/** * Looks up the callback factory with the specified name. * * <p>Will return {@link JDBCCallbackFactory#NULL} if the factory with the specified name can't * be found. */ static JDBCCallbackFactory findCallbackFactory(String factoryName) { if (factoryName != null) { try { Predicate<JDBCCallbackFactory> sameName = f -> factoryName.equalsIgnoreCase(f.getName()); return CALLBACK_REGISTRY.getFactory( JDBCCallbackFactory.class, sameName, null, null); } catch (FactoryRegistryException e) { // pass through } } return JDBCCallbackFactory.NULL; } }
public static synchronized PositionFactory getPositionFactory(Hints hints) throws FactoryRegistryException { hints = mergeSystemHints(hints); return getServiceRegistry() .getFactory(PositionFactory.class, null, hints, Hints.POSITION_FACTORY); } /**
public static synchronized ComplexFactory getComplexFactory(Hints hints) throws FactoryRegistryException { hints = mergeSystemHints(hints); return getServiceRegistry() .getFactory(ComplexFactory.class, null, hints, Hints.COMPLEX_FACTORY); }
public static synchronized AggregateFactory getAggregateFactory(Hints hints) throws FactoryRegistryException { hints = mergeSystemHints(hints); return getServiceRegistry() .getFactory(AggregateFactory.class, null, hints, Hints.AGGREGATE_FACTORY); }
public static synchronized PrimitiveFactory getPrimitiveFactory(Hints hints) throws FactoryRegistryException { hints = mergeSystemHints(hints); return getServiceRegistry() .getFactory(PrimitiveFactory.class, null, hints, Hints.PRIMITIVE_FACTORY); } }
public static synchronized Precision getPrecision(Hints hints) throws FactoryRegistryException { hints = mergeSystemHints(hints); return getServiceRegistry().getFactory(Precision.class, null, hints, Hints.PRECISION); }
/** * An implementation of {@link GeometryFactory} for the provided crs. * * @param hints A set of hints that *must* include a Hints.CRS key * @return a GeometryFactory set up to work with the indicated CRS * @throws FactoryRegistryException if no implementation was found or can be created for the * {@link GeometryFactory} interface. */ public static synchronized GeometryFactory getGeometryFactory(Hints hints) throws FactoryRegistryException { hints = mergeSystemHints(hints); return getServiceRegistry() .getFactory(GeometryFactory.class, null, hints, Hints.GEOMETRY_FACTORY); }
/** * Returns a provider of the specified category. * * @param category The factory category. * @param hints An optional map of hints, or {@code null} if none. * @param key The hint key to use for searching an implementation. * @return The first factory that matches the supplied hints. * @throws FactoryRegistryException if no implementation was found or can be created for the * specified interface. */ private static synchronized <T extends Factory> T getFactory( final Class<T> category, Hints hints, final Hints.Key key) throws FactoryRegistryException { hints = mergeSystemHints(hints); return getServiceRegistry().getFactory(category, null, hints, key); }
/** * Returns the first implementation of {@link PrecisionModel} matching the specified hints. If * no implementation matches, a new one is created if possible or an exception is thrown * otherwise. * * @param hints An optional map of hints, or {@code null} if none. * @return The first precision model that matches the supplied hints. * @throws FactoryRegistryException if no implementation was found or can be created for the * {@link PrecisionModel} category and the given hints. */ public static synchronized PrecisionModel getPrecisionModel(Hints hints) throws FactoryRegistryException { hints = mergeSystemHints(hints); return getServiceRegistry() .getFactory(PrecisionModel.class, null, hints, Hints.JTS_PRECISION_MODEL); }
/** * Looks up a certain factory using two methods: * * <ul> * <li>First and un-synchronized lookup in the hints, should the user have provided the * preferred factroy * <li>A standard SPI registry scan, which has to be fully synchronized * * @param category * @param hints * @param key * @return */ private static <T> T lookup(Class<T> category, Hints hints, Hints.Key key) { // nulls? if (hints == null || key == null) { return null; } // see if the user expressed a preference in the hints final Object hint = hints.get(key); if (hint != null) { if (category.isInstance(hint)) { return category.cast(hint); } } // otherwise do the lousy slow system scan synchronized (CommonFactoryFinder.class) { return getServiceRegistry().getFactory(category, null, hints, key); } }
/** * Returns the first implementation of {@link GeometryFactory} matching the specified hints. If * no implementation matches, a new one is created if possible or an exception is thrown * otherwise. * * <p>Hints that may be understood includes {@link Hints#JTS_COORDINATE_SEQUENCE_FACTORY * JTS_COORDINATE_SEQUENCE_FACTORY}, {@link Hints#JTS_PRECISION_MODEL JTS_PRECISION_MODEL} and * {@link Hints#JTS_SRID JTS_SRID}. * * @param hints An optional map of hints, or {@code null} if none. * @return The first geometry factory that matches the supplied hints. * @throws FactoryRegistryException if no implementation was found or can be created for the * {@link GeometryFactory} category and the given hints. */ public static synchronized GeometryFactory getGeometryFactory(Hints hints) throws FactoryRegistryException { hints = mergeSystemHints(hints); return getServiceRegistry() .getFactory(GeometryFactory.class, null, hints, Hints.JTS_GEOMETRY_FACTORY); } /**
/** * Returns the first implementation of {@link CoordinateSequenceFactory} matching the specified * hints. If no implementation matches, a new one is created if possible or an exception is * thrown otherwise. * * @param hints An optional map of hints, or {@code null} if none. * @return The first coordinate sequence factory that matches the supplied hints. * @throws FactoryRegistryException if no implementation was found or can be created for the * {@link CoordinateSequenceFactory} interface and the given hints. */ public static synchronized CoordinateSequenceFactory getCoordinateSequenceFactory(Hints hints) throws FactoryRegistryException { hints = mergeSystemHints(hints); return getServiceRegistry() .getFactory( CoordinateSequenceFactory.class, null, hints, Hints.JTS_COORDINATE_SEQUENCE_FACTORY); }
/** * Returns the first implementation of a factory matching the specified hints. If no * implementation matches, a new one is created if possible or an exception is thrown otherwise. * If more than one implementation is registered and an {@linkplain #setVendorOrdering ordering * is set}, then the preferred implementation is returned. Otherwise an arbitrary one is * selected. * * @param category The authority factory type. * @param authority The desired authority (e.g. "EPSG"). * @param hints An optional map of hints, or {@code null} if none. * @param key The hint key to use for searching an implementation. * @return The first authority factory that matches the supplied hints. * @throws FactoryRegistryException if no implementation was found or can be created for the * specfied interface. */ private static synchronized <T extends AuthorityFactory> T getAuthorityFactory( final Class<T> category, final String authority, Hints hints, final Hints.Key key) throws FactoryRegistryException { hints = mergeSystemHints(hints); return getServiceRegistry() .getFactory(category, new AuthorityFilter(authority), hints, key); }
/** * Creates an instance from the specified hints. This method recognizes the {@link * Hints#CRS_FACTORY CRS}, {@link Hints#CS_FACTORY CS}, {@link Hints#DATUM_FACTORY DATUM} and * {@link Hints#MATH_TRANSFORM_FACTORY MATH_TRANSFORM} {@code FACTORY} hints. * * @param hints The hints, or {@code null} if none. * @return A factory group created from the specified set of hints. */ public static ReferencingFactoryContainer instance(final Hints hints) { final Hints completed = GeoTools.getDefaultHints(); if (hints != null) { completed.add(hints); } /* * Use the same synchronization lock than ReferencingFactoryFinder (instead of this class) * in order to reduce the risk of dead lock. This is because ReferencingFactoryContainer * creation may queries ReferencingFactoryFinder, and some implementations managed by * ReferencingFactoryFinder may ask for a ReferencingFactoryContainer in turn. */ synchronized (ReferencingFactoryFinder.class) { if (cache == null) { cache = new FactoryCreator( Arrays.asList(new Class<?>[] {ReferencingFactoryContainer.class})); cache.registerFactory( new ReferencingFactoryContainer(null), ReferencingFactoryContainer.class); } return cache.getFactory(ReferencingFactoryContainer.class, null, completed, null); } }
/** * Returns the first implementation of {@link GridCoverageFactory} matching the specified hints. * If no implementation matches, a new one is created if possible or an exception is thrown * otherwise. * * @param hints An optional map of hints, or {@code null} if none. * @return The first grid coverage factory that matches the supplied hints. * @throws FactoryRegistryException if no implementation was found or can be created for the * {@link GridCoverageFactory} interface. * @see Hints#DEFAULT_COORDINATE_REFERENCE_SYSTEM * @see Hints#TILE_ENCODING */ public static GridCoverageFactory getGridCoverageFactory(Hints hints) throws FactoryRegistryException { if (hints != null && hints.containsKey(Hints.GRID_COVERAGE_FACTORY)) { GridCoverageFactory coverageFactory = (GridCoverageFactory) hints.get(Hints.GRID_COVERAGE_FACTORY); if (coverageFactory != null) { return coverageFactory; } } synchronized (CoverageFactoryFinder.class) { hints = mergeSystemHints(hints); return getServiceRegistry().getFactory(GridCoverageFactory.class, null, hints, null); } }
final FactoryNotFoundException notFound; try { return super.getFactory(category, filter, hints, key); } catch (FactoryNotFoundException exception) {