Refine search
static synchronized <T extends DataAccessFactory> Iterator<T> getAllDataStores( FactoryRegistry registry, Class<T> category) { return registry.getServiceProviders(category, null, null); }
/** * 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(); } }
/** * 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(final Hints hints) throws FactoryRegistryException { return (PrecisionModel) getServiceRegistry().getServiceProvider( PrecisionModel.class, null, hints, Hints.JTS_PRECISION_MODEL); }
/** * 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 <T> void scanForPluginsIfNeeded(final Class<?> category) { if (needScanForPlugins != null && needScanForPlugins.remove(category)) { if (needScanForPlugins.isEmpty()) { needScanForPlugins = null; } 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() { final Set<ClassLoader> loaders = getClassLoaders(); for (final Iterator<Class<?>> categories=getCategories(); categories.hasNext();) { final Class<?> category = categories.next(); scanForPlugins(loaders, category); } }
synchronizeIteratorProviders(); Iterator iterator = getServiceProviders(category, hintsFilter, true); if (!iterator.hasNext()) { scanForPlugins(getClassLoaders(), category); iterator = getServiceProviders(category, hintsFilter, true);
Iterator iterator = getServiceProviders(category, true); if (!iterator.hasNext()) { scanForPlugins(getClassLoaders(), category); iterator = getServiceProviders(category, true);
if (category.isAssignableFrom(candidate)) { final Class<? extends T> factoryClass = candidate.asSubclass(category); T factory = getServiceProviderByClass(factoryClass); if (factory == null) try { factory = factoryClass.newInstance(); if (registerServiceProvider(factory, category)) { message.append(System.getProperty("line.separator", "\n")); message.append(" "); for (final Iterator<T> it=getServiceProviders(category, false); it.hasNext();) { final T other = it.next(); if (other != factory) { setOrdering(category, factory, other);
return; for (final Iterator categories=getCategories(); categories.hasNext();) { final Class category = (Class) categories.next(); if (getServiceProviders(category, false).hasNext()) { final Iterator it = provider.iterator(category); if (it != null) { final StringBuffer message = getLogHeader(category); if (register(it, category, message)) { log("synchronizeIteratorProviders", message);
for (final Iterator categories=getCategories(); categories.hasNext();) { final Class category = (Class) categories.next(); if (base.isAssignableFrom(category)) { Object impl1 = null; Object impl2 = null; for (final Iterator it=getServiceProviders(category, false); it.hasNext();) { final Object factory = it.next(); if (service1.filter(factory)) impl1 = factory; if (service2.filter(factory)) impl2 = factory; if (impl1!=null && impl2!=null && impl1!=impl2) { if (set) done |= setOrdering(category, impl1, impl2); else done |= unsetOrdering(category, impl1, impl2);
/** * Helper method for the above. */ private <T> boolean setOrUnsetOrdering(final Class<T> category, final boolean set, final Filter service1, final Filter service2) { boolean done = false; T impl1 = null; T impl2 = null; for (final Iterator<? extends T> it=getServiceProviders(category, false); it.hasNext();) { final T factory = it.next(); if (service1.filter(factory)) impl1 = factory; if (service2.filter(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; } }
boolean set = false; final List previous = new ArrayList(); for (final Iterator it=getServiceProviders(category, false); it.hasNext();) { final Object f1 = it.next(); for (int i=previous.size(); --i>=0;) { set |= setOrdering(category, f1, f2); } else if (c < 0) { set |= setOrdering(category, f2, f1);
synchronizeIteratorProviders(); scanForPluginsIfNeeded(category); return getServiceProviders(category, hintsFilter, true);
final StringBuffer message = getLogHeader(category); boolean newServices = false; newServices |= register(lookupProviders(category, loader), category, message); newServices |= registerFromSystemProperty(loader, category, message); final Iterator it = fip[i].iterator(category); if (it != null) { newServices |= register(it, category, message); log("scanForPlugins", message);
throw new RecursiveSearchException(category); scanForPluginsIfNeeded(category); return getServiceProviders(category, true);
loadingFailure(category, error, false); continue; } catch (ExceptionInInitializerError error) { loadingFailure(category, cause, true); loadingFailure(category, error, true); continue; final Object replacement = getServiceProviderByClass(factoryClass); if (replacement != null) { factory = replacement; if (registerServiceProvider(factory, category)) {
/** * Returns the service registry. The registry will be created the first * time this method is invoked. */ private static FactoryRegistry getServiceRegistry() { assert Thread.holdsLock(JTSFactoryFinder.class); if (registry == null) { registry = new FactoryCreator(Arrays.asList(new Class<?>[] { GeometryFactory.class } )); registry.registerServiceProvider( new GeometryFactory(), GeometryFactory.class ); } return registry; }
/** * This method uses the current classpath to look for instances of {@link * ServiceFactory} using the factory spi mechanism. * <p> * Sublcasses should overide this method if they wish to use a diffent plug-in mechanism. * </p> * * @return A list of ServiceFactory plugins, or an empty list if none * could be found. * * @see FactoryRegistry */ public List getServiceFactories() { Iterator f = FactoryRegistry.lookupProviders( ServiceFactory.class ); ArrayList factories = new ArrayList(); while( f.hasNext() ) factories.add( f.next() ); return factories; } }
/** * Constructs a default coverage processor. The {@link #scanForPlugins} method will be * automatically invoked the first time an operation is required. Additional operations * can be added by subclasses with the {@link #addOperation} method. Rendering hints will * be initialized with the following hints: * <p> * <ul> * <li>{@link JAI#KEY_REPLACE_INDEX_COLOR_MODEL} set to {@link Boolean#FALSE}.</li> * <li>{@link JAI#KEY_TRANSFORM_ON_COLORMAP} set to {@link Boolean#FALSE}.</li> * </ul> * * @param hints A set of additional rendering hints, or {@code null} if none. */ public DefaultProcessor(final RenderingHints hints) { registry = new FactoryRegistry(Collections.singleton(Operation.class)); this.hints = new Hints(hints); this.hints.put(JAI.KEY_REPLACE_INDEX_COLOR_MODEL, Boolean.FALSE); this.hints.put(JAI.KEY_TRANSFORM_ON_COLORMAP, Boolean.FALSE); this.hints.put(Hints.GRID_COVERAGE_PROCESSOR, this); // Must overwrites user setting. }
if (classname != null) try { final Class factoryClass = loader.loadClass(classname); Object factory = getServiceProviderByClass(factoryClass); if (factory == null) try { factory = factoryClass.newInstance(); if (registerServiceProvider(factory, category)) { message.append(System.getProperty("line.separator", "\n")); message.append(" "); for (final Iterator it=getServiceProviders(category, false); it.hasNext();) { final Object other = it.next(); if (other != factory) { setOrdering(category, factory, other);