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 intInfinite penalty value which shall force any implementation to become ineligible.protected static final org.apache.commons.logging.Loglogger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDiscovers all implementations in the application's classpath.getAdditionalPenalty(String className) Returns the additional penalty value set for a particular implementation class.intReturns 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 ofImageLoaderFactoryinstances that support the MIME type indicated by anImageInfoobject and can generate the given image flavor.getImageLoaderFactory(ImageInfo imageInfo, ImageFlavor flavor) Returns the best ImageLoaderFactory supporting theImageInfoand image flavor.Returns an iterator over all registered ImagePreloader instances.static ImageImplRegistryReturns the default instance of the Image implementation registry.voidregisterConverter(ImageConverter converter) Registers a new ImageConverter.voidregisterLoaderFactory(ImageLoaderFactory loaderFactory) Registers a new ImageLoaderFactory.voidregisterPreloader(ImagePreloader preloader) Registers a new ImagePreloader.voidsetAdditionalPenalty(String className, Penalty penalty) Sets an additional penalty for a particular implementation class for any of the interface administered by this registry class.voidsetICCConverter(String iccConverter)
-
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 theImageInfoand 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 ofImageLoaderFactoryinstances that support the MIME type indicated by anImageInfoobject 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
-
setICCConverter
-
getIccConverter
-