Class ServiceLoader
- java.lang.Object
-
- org.apache.maven.surefire.providerapi.ServiceLoader
-
public final class ServiceLoader extends java.lang.Object
SPI loader for Surefire/Failsafe should usecurrent ClassLoader
.
TheServiceLoader
embedded in JVM usesSystem ClassLoader
and cannot be used in Surefire/Failsafe.- Since:
- 2.20
-
-
Constructor Summary
Constructors Constructor Description ServiceLoader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.io.BufferedReader
getReader(java.net.URL url)
<T> java.util.Set<T>
load(java.lang.Class<T> clazz, java.lang.ClassLoader classLoader)
java.util.Set<java.lang.String>
lookup(java.lang.Class<?> clazz, java.lang.ClassLoader classLoader)
private static java.util.Set<java.lang.String>
lookupSpiImplementations(java.util.Enumeration<java.net.URL> urlEnumeration)
Method loadServices loads the services of a class that are defined using the SPI mechanism.
-
-
-
Method Detail
-
load
@Nonnull public <T> java.util.Set<T> load(java.lang.Class<T> clazz, java.lang.ClassLoader classLoader)
-
lookup
@Nonnull public java.util.Set<java.lang.String> lookup(java.lang.Class<?> clazz, java.lang.ClassLoader classLoader) throws java.io.IOException
- Throws:
java.io.IOException
-
lookupSpiImplementations
@Nonnull private static java.util.Set<java.lang.String> lookupSpiImplementations(java.util.Enumeration<java.net.URL> urlEnumeration) throws java.io.IOException
Method loadServices loads the services of a class that are defined using the SPI mechanism.- Parameters:
urlEnumeration
- The urls from the resource- Returns:
- The set of service provider names
- Throws:
java.io.IOException
- When reading the streams fails
-
getReader
@Nonnull private static java.io.BufferedReader getReader(@Nonnull java.net.URL url) throws java.io.IOException
- Throws:
java.io.IOException
-
-