# HG changeset patch # User prr # Date 1512409114 28800 # Node ID 40afd72303e96e3494c46e90b8320c456a01b26d # Parent baad9dc0eab1e48b24597219aa700733d8db39f7 8182610: Update specification of service providers for IIORegistry and ServiceRegistry Reviewed-by: serb, psandoz diff -r baad9dc0eab1 -r 40afd72303e9 src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java --- a/src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java Sun Dec 03 13:21:41 2017 +0000 +++ b/src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java Mon Dec 04 09:38:34 2017 -0800 @@ -56,46 +56,24 @@ import java.util.ServiceConfigurationError; /** - * A registry for service provider instances. Service provider - * classes may be detected at run time by means of meta-information in - * the JAR files containing them. The intent is that it be relatively - * inexpensive to load and inspect all available service provider - * classes. These classes may them be used to locate and instantiate + * A registry for Image I/O service provider instances. Service provider + * classes may be discovered at runtime by the mechanisms documented in + * {@link java.util.ServiceLoader ServiceLoader}. + * + * The intent is that it be relatively inexpensive to load and inspect + * all available Image I/O service provider classes. + * These classes may then be used to locate and instantiate * more heavyweight classes that will perform actual work, in this * case instances of {@code ImageReader}, * {@code ImageWriter}, {@code ImageTranscoder}, * {@code ImageInputStream}, and {@code ImageOutputStream}. * - * Service providers found from the Java platform are automatically + * Service providers included in the Java runtime are automatically * loaded as soon as this class is instantiated. * *

When the {@code registerApplicationClasspathSpis} method - * is called, service provider instances declared in the - * meta-information section of JAR files on the application class path - * are loaded. To declare a service provider, a {@code services} - * subdirectory is placed within the {@code META-INF} directory - * that is present in every JAR file. This directory contains a file - * for each service provider interface that has one or more - * implementation classes present in the JAR file. For example, if - * the JAR file contained a class named - * {@code com.mycompany.imageio.MyFormatReaderSpi} which - * implements the {@code ImageReaderSpi} interface, the JAR file - * would contain a file named: - * - *

- * META-INF/services/javax.imageio.spi.ImageReaderSpi
- * 
- * - * containing the line: - * - *
- * com.mycompany.imageio.MyFormatReaderSpi
- * 
- * - *

The service provider classes are intended to be lightweight - * and quick to load. Implementations of these interfaces - * should avoid complex dependencies on other classes and on - * native code. + * is called, additional service provider instances will be discovered + * using {@link java.util.ServiceLoader ServiceLoader}. * *

It is also possible to manually add service providers not found * automatically, as well as to remove those that are using the @@ -103,9 +81,8 @@ * the application may customize the contents of the registry as it * sees fit. * - *

For more details on declaring service providers, and the JAR - * format in general, see the - * JAR File Specification. + *

For information on how to create and deploy service providers, + * refer to the documentation on {@link java.util.ServiceLoader ServiceLoader} */ public final class IIORegistry extends ServiceRegistry { diff -r baad9dc0eab1 -r 40afd72303e9 src/java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.java --- a/src/java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.java Sun Dec 03 13:21:41 2017 +0000 +++ b/src/java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.java Mon Dec 04 09:38:34 2017 -0800 @@ -39,19 +39,13 @@ import java.util.ServiceLoader; /** - * A registry for service provider instances. - * - *

A service is a well-known set of interfaces and (usually - * abstract) classes. A service provider is a specific - * implementation of a service. The classes in a provider typically - * implement the interface or subclass the class defined by the - * service itself. + * A registry for service provider instances for Image I/O service types. * *

Service providers are stored in one or more categories, - * each of which is defined by a class of interface (described by a + * each of which is defined by a class or interface (described by a * {@code Class} object) that all of its members must implement. * - *

The set of categories supported is limited + *

The set of categories supported by this class is limited * to the following standard Image I/O service types: * *

* *

An attempt to load a provider that is not a subtype of one of the - * above types will result in {@code IllegalArgumentException}. For - * a general mechanism to load service providers, see - * {@link java.util.ServiceLoader ServiceLoader}. + * above types will result in {@code IllegalArgumentException}. + *

For the general mechanism to load service providers, see + * {@link java.util.ServiceLoader ServiceLoader}, which is + * the underlying standard mechanism used by this class. * *

Only a single instance of a given leaf class (that is, the * actual class returned by {@code getClass()}, as opposed to any @@ -80,24 +75,7 @@ * the previous instance. In practice, service provider objects are * usually singletons so this behavior is appropriate. * - *

To declare a service provider, a {@code services} - * subdirectory is placed within the {@code META-INF} directory - * that is present in every JAR file. This directory contains a file - * for each service provider interface that has one or more - * implementation classes present in the JAR file. For example, if - * the JAR file contained a class named - * {@code com.mycompany.mypkg.GreenImageReaderProvider} which implements the - * {@code javax.imageio.spi.ImageReaderSpi} interface, the JAR file - * would contain a file named:

- * META-INF/services/javax.imageio.spi.ImageReaderSpi
- * - * containing the line: - * - *
- * com.mycompany.mypkg.GreenImageReaderProvider
- * 
- * - *

The service provider classes should be to be lightweight and + *

The service provider classes should be lightweight and * quick to load. Implementations of these interfaces should avoid * complex dependencies on other classes and on native code. The usual * pattern for more complex services is to register a lightweight @@ -106,9 +84,8 @@ *

An application may customize the contents of a registry as it * sees fit, so long as it has the appropriate runtime permission. * - *

For more details on declaring service providers, and the JAR - * format in general, see the - * JAR File Specification. + *

For information on how to create and deploy service providers, + * refer to the documentation on {@link java.util.ServiceLoader ServiceLoader} * * @see RegisterableService * @see java.util.ServiceLoader