/** * Invokes {@link #createServiceProvider}, but checks against recursive calls. If the specified * implementation is already under construction, returns {@code null} in order to tell to {@link * #getFactory} that it need to search for an other implementation. This is needed for avoiding * infinite recursivity when a factory is a wrapper around an ther factory of the same category. * For example this is the case of {@link * org.geotools.referencing.operation.BufferedCoordinateOperationFactory}. */ private <T> T createSafe( final Class<T> category, final Class<?> implementation, final Hints hints) { if (!underConstruction.add(implementation)) { return null; } try { return createServiceProvider(category, implementation, hints); } finally { if (!underConstruction.remove(implementation)) { throw new AssertionError(); } } }
/** * Creates a new instance of the specified factory using the specified hints. * * @param category The category to instantiate. * @param implementation The factory class to instantiate. * @param hints The implementation hints. * @return The factory. * @throws FactoryRegistryException if the factory creation failed. */ protected Object createServiceProvider( final Class category, final Class implementation, final Hints hints) throws FactoryRegistryException { if (GeometryFactory.class.isAssignableFrom(category) && GeometryFactory.class.equals(implementation)) { return new GeometryFactory( getPrecisionModel(hints), getSRID(hints), getCoordinateSequenceFactory(hints)); } return super.createServiceProvider(category, implementation, hints); }