static synchronized <T extends DataAccessFactory> Iterator<T> getAllDataStores( FactoryRegistry registry, Class<T> category) { return registry.getFactories(category, null, null).iterator(); }
public static synchronized Map<String, GranuleHandlerFactorySPI> getGranuleHandlersSPI() { // get all GranuleHandlerFactorySPI implementations FactoryRegistry serviceRegistry = getServiceRegistry(); serviceRegistry.scanForPlugins(); return serviceRegistry .getFactories(GranuleHandlerFactorySPI.class, true) .collect(toInstanceByClassNameMap()); }
/** * @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); }
if (spiExtensions == null) { spiExtensions = new ArrayList<Object>(); new FactoryRegistry(extensionPoint) .getFactories(extensionPoint, false) .forEach(spiExtensions::add); spiCache.put(extensionPoint, spiExtensions);
/** * Reinitializes all static state, including the ProcessFactory service registry and reference * to the last used ProcessFactory */ public static synchronized void reset() { if (registry == null) { // nothing to do return; } registry.deregisterAll(); registry.scanForPlugins(); lastFactory = null; }
/** * Scans the given category for plugins only if needed. After this method has been invoked once * for a given category, it will no longer scan for that category. */ private void scanForPluginsIfNeeded(final Class<?> category) { if (needScanForPlugins.remove(category)) { scanForPlugins(getClassLoaders(), category); } }
/** * Scans for factory plug-ins on the application class path. This method is needed because the * application class path can theoretically change, or additional plug-ins may become available. * Rather than re-scanning the classpath on every invocation of the API, the class path is * scanned automatically only on the first invocation. Clients can call this method to prompt a * re-scan. Thus this method need only be invoked by sophisticated applications which * dynamically make new plug-ins available at runtime. */ public void scanForPlugins() { registry.scanForPlugins(); }
if (category.isAssignableFrom(candidate)) { final Class<? extends T> factoryClass = candidate.asSubclass(category); T factory = getFactoryByClass(factoryClass); if (factory == null) try { factory = factoryClass.newInstance(); if (registerFactory(factory, category)) { message.append(System.getProperty("line.separator", "\n")); message.append(" "); Iterable<T> factories = getFactories(category, false)::iterator; for (final T other : factories) { if (other != factory) { setOrdering(category, factory, other);
boolean set = false; final List<T> previous = new ArrayList<>(); Iterable<T> factories = getFactories(category, false)::iterator; for (final T f1 : factories) { for (int i = previous.size(); --i >= 0; ) { set |= setOrdering(category, f1, f2); } else if (c < 0) { set |= setOrdering(category, f2, f1);
/** Helper method for the above. */ private <T> boolean setOrUnsetOrdering( final Class<T> category, final boolean set, final Predicate<? super T> filter1, final Predicate<? super T> filter2) { boolean done = false; T impl1 = null; T impl2 = null; Iterable<T> factories = getFactories(category, false)::iterator; for (final T factory : factories) { if (filter1.test(factory)) impl1 = factory; if (filter2.test(factory)) impl2 = factory; if (impl1 != null && impl2 != null && impl1 != impl2) { if (set) done |= setOrdering(category, impl1, impl2); else done |= unsetOrdering(category, impl1, impl2); } } return done; }
synchronizeIteratorProviders(); scanForPluginsIfNeeded(category); Predicate<T> isAcceptable = factory -> isAcceptable(category.cast(factory), category, hints, filter); return getFactories(category, isAcceptable, true);
throw new RecursiveSearchException(category); scanForPluginsIfNeeded(category); return getFactories(category, true);
registry.streamCategories().sorted(this).collect(toList()); final Iterator<?> providers = registry.getFactories(category, null, null).iterator(); while (providers.hasNext()) { if (implementations.length() != 0) {
/** * 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); } }
/** Resets the factory finder and prepares for a new full scan of the SPI subsystems */ public static void reset() { FactoryRegistry copy = registry; registry = null; if (copy != null) { copy.deregisterAll(); } } }
/** @deprecated Replaced wtih {@link #deregisterFactory(Object)} */ @Deprecated public void registerServiceProvider(final Object provider) { registerFactory(provider); }
loadingFailure(category, error, false); continue; } catch (ExceptionInInitializerError error) { loadingFailure(category, cause, true); loadingFailure(category, error, true); continue; final T replacement = getFactoryByClass(factoryClass); if (replacement != null) { factory = replacement; if (registerFactory(factory, category)) {
/** @deprecated {@link #deregisterFactory(Object, Class)} */ @Deprecated public <T> void deregisterServiceProvider(final T provider, final Class<T> category) { deregisterFactory(provider); }
/** * Constructs a default {@link MathTransform math transform} factory using the specified * {@linkplain MathTransformProvider transform providers} categories. * * @param categories The providers categories, as implementations of {@link * MathTransformProvider}. */ private DefaultMathTransformFactory(final Class<?>[] categories) { registry = new FactoryRegistry(Arrays.asList(categories)); pool = CanonicalSet.newInstance(MathTransform.class); }
/** * Scans for factory plug-ins on the application class path. This method is needed because the * application class path can theoretically change, or additional plug-ins may become available. * Rather than re-scanning the classpath on every invocation of the API, the class path is * scanned automatically only on the first invocation. Clients can call this method to prompt a * re-scan. Thus this method need only be invoked by sophisticated applications which * dynamically make new plug-ins available at runtime. */ public static void scanForPlugins() { if (registry != null) { registry.scanForPlugins(); } }