public final class SoftServiceLoader<S> extends java.lang.Object implements java.lang.Iterable
Variation of java.util.ServiceLoader that allows soft loading and conditional loading of META-INF/services classes.
S
- The service typeModifiers | Name | Description |
---|---|---|
private class |
SoftServiceLoader.ServiceLoaderIterator |
A service loader iterator implementation. |
Modifiers | Name | Description |
---|---|---|
private static boolean |
ENABLE_CLASS_LOADER_LOGGING |
|
static java.lang.String |
META_INF_SERVICES |
|
static java.lang.String |
PROPERTY_GRAILS_CLASSLOADER_LOGGING |
|
static org.slf4j.Logger |
REFLECTION_LOGGER |
|
private java.lang.ClassLoader |
classLoader |
|
private java.util.function.Predicate<java.lang.String> |
condition |
|
java.util.Iterator<ServiceDefinition<S>> |
loaded |
|
private java.util.Map<java.lang.String, ServiceDefinition<S>> |
loadedServices |
|
private java.lang.Class<S> |
serviceType |
|
private java.util.Iterator<ServiceDefinition<S>> |
unloadedServices |
Constructor and description |
---|
private SoftServiceLoader
(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader) |
private SoftServiceLoader
(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader, java.util.function.Predicate<java.lang.String> condition) |
Type Params | Return Type | Name and description |
---|---|---|
|
public java.util.Optional<ServiceDefinition<S>> |
first()
|
|
public java.util.Optional<ServiceDefinition<S>> |
firstOr(java.lang.String alternative, java.lang.ClassLoader classLoader)
|
|
public static org.slf4j.Logger |
getLogger(java.lang.Class type) Special case getLogger method that should be used by classes that are used in the annotation processor. |
|
public boolean |
hasNext() |
|
public java.util.Iterator<ServiceDefinition<S>> |
iterator()
|
<S> |
public static SoftServiceLoader<S> |
load(java.lang.Class<S> service) Creates a new SoftServiceLoader using the thread context loader by default. |
<S> |
public static SoftServiceLoader<S> |
load(java.lang.Class<S> service, java.lang.ClassLoader loader) Creates a new SoftServiceLoader using the given type and class loader. |
<S> |
public static SoftServiceLoader<S> |
load(java.lang.Class<S> service, java.lang.ClassLoader loader, java.util.function.Predicate<java.lang.String> condition) Creates a new SoftServiceLoader using the given type and class loader. |
|
protected ServiceDefinition<S> |
newService(java.lang.String name, java.util.Optional<java.lang.Class> loadedClass)
|
|
public ServiceDefinition<S> |
next() |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
alternative
- An alternative type to use if the this type is not presentclassLoader
- The classloader Special case getLogger
method that should be used by classes that are used in the annotation processor.
type
- The type
Creates a new SoftServiceLoader using the thread context loader by default.
service
- The service typeS
- The service generic typeCreates a new SoftServiceLoader using the given type and class loader.
service
- The service typeloader
- The class loaderS
- The service generic typeCreates a new SoftServiceLoader using the given type and class loader.
service
- The service typeloader
- The class loader to usecondition
- A java.util.function.Predicate to use to conditionally load the service. The predicate is passed the service class nameS
- The service generic type
name
- The nameloadedClass
- The loaded class