/*
* @(#)ImageIO.java 1.89 05/12/21
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.imageio;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.security.AccessController;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
import javax.imageio.spi.IIORegistry;
import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.spi.ImageReaderWriterSpi;
import javax.imageio.spi.ImageWriterSpi;
import javax.imageio.spi.ImageInputStreamSpi;
import javax.imageio.spi.ImageOutputStreamSpi;
import javax.imageio.spi.ImageTranscoderSpi;
import javax.imageio.spi.ServiceRegistry;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.ImageOutputStream;
import sun.awt.AppContext;
import sun.security.action.GetPropertyAction;
/**
* A class containing static convenience methods for locating
* <code>ImageReader</code>s and <code>ImageWriter</code>s, and
* performing simple encoding and decoding.
*
* @version 0.5
*/
public final class ImageIO {
private static final IIORegistry theRegistry =
IIORegistry.getDefaultInstance();
/**
* Constructor is private to prevent instantiation.
*/
private ImageIO() {}
/**
* Scans for plug-ins on the application class path,
* loads their service provider classes, and registers a service
* provider instance for each one found with the
* <code>IIORegistry</code>.
*
* <p>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.
*
* <p> The <code>getResources</code> method of the context
* <code>ClassLoader</code> is used locate JAR files containing
* files named
* <code>META-INF/services/javax.imageio.spi.</code><i>classname</i>,
* where <i>classname</i> is one of <code>ImageReaderSpi</code>,
* <code>ImageWriterSpi</code>, <code>ImageTranscoderSpi</code>,
* <code>ImageInputStreamSpi</code>, or
* <code>ImageOutputStreamSpi</code>, along the application class
* path.
*
* <p> The contents of the located files indicate the names of
* actual implementation classes which implement the
* aforementioned service provider interfaces; the default class
* loader is then used to load each of these classes and to
* instantiate an instance of each class, which is then placed
* into the registry for later retrieval.
*
* <p> The exact set of locations searched depends on the
* implementation of the Java runtime enviroment.
*
* @see ClassLoader#getResources
*/
public static void scanForPlugins() {
theRegistry.registerApplicationClasspathSpis();
}
// ImageInputStreams
/**
* A class to hold information about caching. Each
* <code>ThreadGroup</code> will have its own copy
=1= |