Class ImageImplRegistry
java.lang.Object
org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry
This class is the registry for all implementations of the various service provider interfaces
for the image package.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Infinite penalty value which shall force any implementation to become ineligible.protected static final org.apache.commons.logging.Log
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Discovers all implementations in the application's classpath.getAdditionalPenalty
(String className) Returns the additional penalty value set for a particular implementation class.int
Returns the number of modifications to the collection of registered ImageConverter instances.Returns the Collection of registered ImageConverter instances.Returns an array of ImageLoaderFactory instances which support the given MIME type.getImageLoaderFactories
(ImageInfo imageInfo, ImageFlavor flavor) Returns an array ofImageLoaderFactory
instances that support the MIME type indicated by anImageInfo
object and can generate the given image flavor.getImageLoaderFactory
(ImageInfo imageInfo, ImageFlavor flavor) Returns the best ImageLoaderFactory supporting theImageInfo
and image flavor.Returns an iterator over all registered ImagePreloader instances.static ImageImplRegistry
Returns the default instance of the Image implementation registry.void
registerConverter
(ImageConverter converter) Registers a new ImageConverter.void
registerLoaderFactory
(ImageLoaderFactory loaderFactory) Registers a new ImageLoaderFactory.void
registerPreloader
(ImagePreloader preloader) Registers a new ImagePreloader.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.
-
Field Details
-
log
protected static final org.apache.commons.logging.Log loglogger -
INFINITE_PENALTY
public static final int INFINITE_PENALTYInfinite 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
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
Registers a new ImagePreloader.- Parameters:
preloader
- An ImagePreloader instance
-
registerLoaderFactory
Registers a new ImageLoaderFactory.- Parameters:
loaderFactory
- An ImageLoaderFactory instance
-
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
Registers a new ImageConverter.- Parameters:
converter
- An ImageConverter instance
-
getPreloaderIterator
Returns an iterator over all registered ImagePreloader instances.- Returns:
- an iterator over ImagePreloader instances.
-
getImageLoaderFactory
Returns the best ImageLoaderFactory supporting theImageInfo
and image flavor. If there are multiple ImageLoaderFactories the one with the least usage penalty is selected.- Parameters:
imageInfo
- the image info objectflavor
- the image flavor.- Returns:
- an ImageLoaderFactory instance or null, if no suitable implementation was found
-
getImageLoaderFactories
Returns an array ofImageLoaderFactory
instances that support the MIME type indicated by anImageInfo
object and can generate the given image flavor.- Parameters:
imageInfo
- the image info objectflavor
- the target image flavor- Returns:
- the array of image loader factories
-
getImageLoaderFactories
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
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 classpenalty
- the additional penalty or null to clear any existing value
-
getAdditionalPenalty
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
-