Tabnine Logo
FactoryRegistry
Code IndexAdd Tabnine to your IDE (free)

How to use
FactoryRegistry
in
org.geotools.factory

Best Java code snippets using org.geotools.factory.FactoryRegistry (Showing top 20 results out of 315)

Refine searchRefine arrow

  • Stream
origin: org.geotools/gt-main

static synchronized <T extends DataAccessFactory> Iterator<T> getAllDataStores(
    FactoryRegistry registry, Class<T> category) {
  return registry.getServiceProviders(category, null, null);
}
origin: org.geotools/gt2-main

/**
 * 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();
  }
}
origin: org.geotools/gt2-main

/**
 * 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);
}
origin: org.geotools/gt-metadata

/**
 * 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);
  }
}
origin: org.geotools/gt-metadata

/**
 * 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);
  }
}
origin: org.geotools/gt2-metadata

synchronizeIteratorProviders();
Iterator iterator = getServiceProviders(category, hintsFilter, true);
if (!iterator.hasNext()) {
  scanForPlugins(getClassLoaders(), category);
  iterator = getServiceProviders(category, hintsFilter, true);
origin: org.geotools/gt2-metadata

Iterator iterator = getServiceProviders(category, true);
if (!iterator.hasNext()) {
  scanForPlugins(getClassLoaders(), category);
  iterator = getServiceProviders(category, true);
origin: org.geotools/gt-metadata

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);
origin: org.geotools/gt2-metadata

  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);
origin: org.geotools/gt2-metadata

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);
origin: org.geotools/gt-metadata

  /**
   * 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;
  }
}
origin: org.geotools/gt2-metadata

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);
origin: org.geotools/gt-metadata

synchronizeIteratorProviders();
scanForPluginsIfNeeded(category);
return getServiceProviders(category, hintsFilter, true);
origin: org.geotools/gt2-metadata

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);
origin: org.geotools/gt-metadata

  throw new RecursiveSearchException(category);
scanForPluginsIfNeeded(category);
return getServiceProviders(category, true);
origin: org.geotools/gt2-metadata

  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)) {
origin: org.geotools/gt-main

/**
 * 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;
}
origin: org.geotools/gt2-main

  /**
   * 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;
  }
}
origin: org.geotools/gt2-coverage

/**
 * 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.
}
origin: org.geotools/gt2-metadata

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);
org.geotools.factoryFactoryRegistry

Javadoc

A registry for factories, organized by categories (usualy by interface). For example org.opengis.referencing.crs.CRSFactory.class is a category, and org.opengis.referencing.operation.MathTransformFactory.class is an other category.

For each category, implementations are registered in a file placed in the META-INF/services/ directory, as specified in the ServiceRegistryjavadoc. Those files are usually bundled into the JAR file distributed by the vendor. If the same META-INF/services/ file appears many time in different JARs, they are processed as if their content were merged.

Example use:

Set categories = Collections.singleton(new Class[] {MathTransformProvider.class});
FactoryRegistry registry = new FactoryRegistry(categories);

// get the providers
Filter filter = null;
Hints hints = null;
Iterator providers = registry.getServiceProviders(MathTransformProvider.class, filter, hints);

NOTE: This class is not thread safe. Users are responsable for synchronisation. This is usually done in an utility class wrapping this service registry (e.g. org.geotools.referencing.ReferencingFactoryFinder).

Most used methods

  • getServiceProviders
  • scanForPlugins
    Scans for factory plug-ins of the given category, with guard against recursivities. The recursivity
  • getServiceProvider
    Returns the first provider in the registry for the specified category, using the specified map of hi
  • lookupProviders
  • registerServiceProvider
  • <init>
    Constructs a new registry for the specified categories.
  • debug
    Log a debug message for #getServiceProvider method. Note: we are not required to insert the method n
  • getCachedProviders
    Returns the providers available in the cache, or null if none. To be overridden by FactoryCreator on
  • getCategories
  • getClassLoaders
    Returns all class loaders to be used for scanning plugins. Current implementation returns the follow
  • getFactories
  • getLogHeader
    Prepares a message to be logged if any provider has been registered.
  • getFactories,
  • getLogHeader,
  • getServiceImplementation,
  • getServiceProviderByClass,
  • getUnfilteredProviders,
  • isAcceptable,
  • isAvailable,
  • loadingFailure,
  • log,
  • register

Popular in Java

  • Making http post requests using okhttp
  • startActivity (Activity)
  • getApplicationContext (Context)
  • addToBackStack (FragmentTransaction)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now