|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.groboutils.util.classes.v1.SPILoader
Loads Service Provider Interface (SPI) classes from the given classloader (if any). This will search for files in the form /META-INF/services/classname. The discovered file will be parsed using java.util.Properties parsing method, but only the keys will be recognized (note that if a line contains no ':' or '=', then the line will be recognized as a key with an empty-string value). The found keys will be used as class names, constructed, and returned, using the ClassLoadHelper class in this package.
This is intended to follow the SPI interface spec, partially described in the JDK 1.4 documentation in the package docs for java.awt.im.spi.
Note that by using a Properties instance, this class is limited to only one instance of a class type per META-INF service file. This is assumed to be an adequate restriction, since in most circumstances, there should only be one instance of a service provider loaded per need.
Constructor Summary | |
SPILoader(java.lang.Class spiBase)
Use the context (thread) classloader or the system class loader. |
|
SPILoader(java.lang.Class spiBase,
java.lang.ClassLoader cl)
Create a new SPILoader, loading the service files from the given class loader classpath. |
Method Summary | |
boolean |
hasNext()
Discovers if there is another provider class instance to load. |
java.lang.Object |
nextProvier()
Returns a new instance of the next class name. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SPILoader(java.lang.Class spiBase) throws java.io.IOException
spiBase
- the base class that all loaded SPI classes must
implement. This is also used to define the name of the files
to load from the META-INF directory.
java.io.IOException
- if there is an I/O problem loading the
initial set of resources.public SPILoader(java.lang.Class spiBase, java.lang.ClassLoader cl) throws java.io.IOException
spiBase
- the base class that all loaded SPI classes must
implement. This is also used to define the name of the files
to load from the META-INF directory.cl
- classloader to load files from.
java.io.IOException
- if there is an I/O problem loading the
initial set of resources.Method Detail |
public boolean hasNext() throws java.io.IOException
java.io.IOException
public java.lang.Object nextProvier() throws java.io.IOException
java.io.IOException
- if there was an I/O error, or if the referenced
resource defines an invalid class to load.
java.util.NoSuchElementException
- if the enumeration is already at
the end of the list.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |