/** * Constructs a new registry for the specified categories. * * @param categories The categories. */ public FactoryRegistry(final Collection<Class<?>> categories) { super(categories.iterator()); for (final Iterator<Class<?>> it=getCategories(); it.hasNext();) { if (needScanForPlugins == null) { needScanForPlugins = new HashSet<Class<?>>(); } needScanForPlugins.add(it.next()); } }
/** * Sets or unsets a pairwise ordering between all factories meeting a criterion. For example * in the CRS framework ({@link org.geotools.referencing.FactoryFinder}), this is used for * setting ordering between all factories provided by two vendors, or for two authorities. * If one or both factories are not currently registered, or if the desired ordering is * already set/unset, nothing happens and false is returned. * * @param <T> The class represented by the {@code base} argument. * @param base The base category. Only categories {@linkplain Class#isAssignableFrom * assignable} to {@code base} will be processed. * @param set {@code true} for setting the ordering, or {@code false} for unsetting. * @param service1 Filter for the preferred factory. * @param service2 Filter for the factory to which {@code service1} is preferred. * @return {@code true} if the ordering changed as a result of this call. */ public <T> boolean setOrdering(final Class<T> base, final boolean set, final Filter service1, final Filter service2) { boolean done = false; for (final Iterator<Class<?>> categories=getCategories(); categories.hasNext();) { final Class<?> candidate = categories.next(); if (base.isAssignableFrom(candidate)) { final Class<? extends T> category = candidate.asSubclass(base); done |= setOrUnsetOrdering(category, set, service1, service2); } } return done; }
/** * 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() { final Set<ClassLoader> loaders = getClassLoaders(); for (final Iterator<Class<?>> categories=getCategories(); categories.hasNext();) { final Class<?> category = categories.next(); scanForPlugins(loaders, 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() { final Set loaders = getClassLoaders(); for (final Iterator categories=getCategories(); categories.hasNext();) { final Class category = (Class) categories.next(); scanForPlugins(loaders, category); } }
return; for (final Iterator<Class<?>> categories=getCategories(); categories.hasNext();) { final Class<?> category = categories.next(); if (needScanForPlugins == null || !needScanForPlugins.contains(category)) {
for (final Iterator categories=getCategories(); categories.hasNext();) { final Class category = (Class) categories.next(); if (base.isAssignableFrom(category)) {
return; for (final Iterator categories=getCategories(); categories.hasNext();) { final Class category = (Class) categories.next(); if (getServiceProviders(category, false).hasNext()) {