CONTENTS | PREV | NEXT |
In order for
plug-ins to be added to a running Java Virtual Machine, they must be compiled into
Java bytecode files (class files). These class files will contain
the code for subclasses of various classes defined by the API. For
example, a plug-in that pr ovides the capability to read images
will include a new subclass of the abstract
javax.imageio.ImageReader
class defined by the API.
The usual reversed Internet domain name convention may be used to
guarantee uniqueness of class names.
Because loading and instantiating an entire plug-in may be expensive, an additional class is used as a "stand-in" to provide information about the plug-in. This class may be used, for example, to determine what formats are handled by the plug-in p rior to actually instantiating the plug-in.
The "stand-in" object is lightweight enough that it can be loaded and a single instance instantiated every time the API is used within a given invocation of the Java virtual machine. This pattern, in which a small class is used to provide informat ion about an available service, is referred to as a "service provider interface."