Package org.apache.lucene.util
Class SPIClassIterator<S>
- java.lang.Object
-
- org.apache.lucene.util.SPIClassIterator<S>
-
- All Implemented Interfaces:
java.util.Iterator<java.lang.Class<? extends S>>
public final class SPIClassIterator<S> extends java.lang.Object implements java.util.Iterator<java.lang.Class<? extends S>>Helper class for loading SPI classes from classpath (META-INF files). This is a light impl ofServiceLoaderbut is guaranteed to be bug-free regarding classpath order and does not instantiate or initialize the classes found.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<S>clazzprivate java.util.Iterator<java.lang.String>linesIteratorprivate java.lang.ClassLoaderloaderprivate static java.lang.StringMETA_INF_SERVICESprivate java.util.Enumeration<java.net.URL>profilesEnum
-
Constructor Summary
Constructors Modifier Constructor Description privateSPIClassIterator(java.lang.Class<S> clazz, java.lang.ClassLoader loader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <S> SPIClassIterator<S>get(java.lang.Class<S> clazz)Creates a new SPI iterator to lookup services of typeclazzusing the sameClassLoaderas the argument.static <S> SPIClassIterator<S>get(java.lang.Class<S> clazz, java.lang.ClassLoader loader)Creates a new SPI iterator to lookup services of typeclazzusing the given classloader.booleanhasNext()static booleanisParentClassLoader(java.lang.ClassLoader parent, java.lang.ClassLoader child)Utility method to check if some class loader is a (grand-)parent of or the same as another one.private booleanloadNextProfile()java.lang.Class<? extends S>next()voidremove()
-
-
-
Field Detail
-
META_INF_SERVICES
private static final java.lang.String META_INF_SERVICES
- See Also:
- Constant Field Values
-
clazz
private final java.lang.Class<S> clazz
-
loader
private final java.lang.ClassLoader loader
-
profilesEnum
private final java.util.Enumeration<java.net.URL> profilesEnum
-
linesIterator
private java.util.Iterator<java.lang.String> linesIterator
-
-
Constructor Detail
-
SPIClassIterator
private SPIClassIterator(java.lang.Class<S> clazz, java.lang.ClassLoader loader)
-
-
Method Detail
-
get
public static <S> SPIClassIterator<S> get(java.lang.Class<S> clazz)
Creates a new SPI iterator to lookup services of typeclazzusing the sameClassLoaderas the argument.
-
get
public static <S> SPIClassIterator<S> get(java.lang.Class<S> clazz, java.lang.ClassLoader loader)
Creates a new SPI iterator to lookup services of typeclazzusing the given classloader.
-
isParentClassLoader
public static boolean isParentClassLoader(java.lang.ClassLoader parent, java.lang.ClassLoader child)Utility method to check if some class loader is a (grand-)parent of or the same as another one. This means the child will be able to load all classes from the parent, too.If caller's codesource doesn't have enough permissions to do the check,
falseis returned (this is fine, because if we get aSecurityExceptionit is for sure no parent).
-
loadNextProfile
private boolean loadNextProfile()
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<S>
-
next
public java.lang.Class<? extends S> next()
- Specified by:
nextin interfacejava.util.Iterator<S>
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<S>
-
-