Class ImageImplRegistry

java.lang.Object
org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry

public class ImageImplRegistry extends Object
This class is the registry for all implementations of the various service provider interfaces for the image package.
  • Field Details

    • log

      protected static final org.apache.commons.logging.Log log
      logger
    • INFINITE_PENALTY

      public static final int INFINITE_PENALTY
      Infinite penalty value which shall force any implementation to become ineligible.
      See Also:
  • Constructor Details

    • ImageImplRegistry

      public ImageImplRegistry(boolean discover)
      Main constructor. This constructor allows to disable plug-in discovery for testing purposes.
      Parameters:
      discover - true if implementation classes shall automatically be discovered.
    • ImageImplRegistry

      public ImageImplRegistry()
      Main constructor.
  • Method Details

    • newInstance

      public static ImageImplRegistry newInstance()
      Returns the default instance of the Image implementation registry.
      Returns:
      the default instance
    • discoverClasspathImplementations

      public void discoverClasspathImplementations()
      Discovers all implementations in the application's classpath.
    • registerPreloader

      public void registerPreloader(ImagePreloader preloader)
      Registers a new ImagePreloader.
      Parameters:
      preloader - An ImagePreloader instance
    • registerLoaderFactory

      public void registerLoaderFactory(ImageLoaderFactory loaderFactory)
      Registers a new ImageLoaderFactory.
      Parameters:
      loaderFactory - An ImageLoaderFactory instance
    • getImageConverters

      public Collection getImageConverters()
      Returns the Collection of registered ImageConverter instances.
      Returns:
      a Collection<ImageConverter>
    • getImageConverterModifications

      public int getImageConverterModifications()
      Returns the number of modifications to the collection of registered ImageConverter instances. This is used to detect changes in the registry concerning ImageConverters.
      Returns:
      the number of modifications
    • registerConverter

      public void registerConverter(ImageConverter converter)
      Registers a new ImageConverter.
      Parameters:
      converter - An ImageConverter instance
    • getPreloaderIterator

      public Iterator getPreloaderIterator()
      Returns an iterator over all registered ImagePreloader instances.
      Returns:
      an iterator over ImagePreloader instances.
    • getImageLoaderFactory

      public ImageLoaderFactory getImageLoaderFactory(ImageInfo imageInfo, ImageFlavor flavor)
      Returns the best ImageLoaderFactory supporting the ImageInfo and image flavor. If there are multiple ImageLoaderFactories the one with the least usage penalty is selected.
      Parameters:
      imageInfo - the image info object
      flavor - the image flavor.
      Returns:
      an ImageLoaderFactory instance or null, if no suitable implementation was found
    • getImageLoaderFactories

      public ImageLoaderFactory[] getImageLoaderFactories(ImageInfo imageInfo, ImageFlavor flavor)
      Returns an array of ImageLoaderFactory instances that support the MIME type indicated by an ImageInfo object and can generate the given image flavor.
      Parameters:
      imageInfo - the image info object
      flavor - the target image flavor
      Returns:
      the array of image loader factories
    • getImageLoaderFactories

      public ImageLoaderFactory[] getImageLoaderFactories(String mime)
      Returns an array of ImageLoaderFactory instances which support the given MIME type. The instances are returned in no particular order.
      Parameters:
      mime - the MIME type to find ImageLoaderFactories for
      Returns:
      the array of ImageLoaderFactory instances
    • setAdditionalPenalty

      public void setAdditionalPenalty(String className, Penalty penalty)
      Sets an additional penalty for a particular implementation class for any of the interface administered by this registry class. No checking is performed to verify if the className parameter is valid.
      Parameters:
      className - the fully qualified class name of the implementation class
      penalty - the additional penalty or null to clear any existing value
    • getAdditionalPenalty

      public Penalty getAdditionalPenalty(String className)
      Returns the additional penalty value set for a particular implementation class. If no such value is set, 0 is returned.
      Parameters:
      className - the fully qualified class name of the implementation class
      Returns:
      the additional penalty value