public class ServiceProviderFinder extends Object
ServiceLoader
.
A service is defined by an interface or an abstract class.Constructor and Description |
---|
ServiceProviderFinder() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
findAnyServiceProvider(Class<T> klass)
Finds any provider for a given service.
|
static <T> List<T> |
findServiceProviders(Class<T> klass)
Finds all providers for a given service.
|
static <T> T |
loadAnyServiceProvider(Class<T> klass)
Returns any provider for a given service and throws an exception when no provider
is found on the classpath.
|
static <T> T |
loadUniqueServiceProvider(Class<T> klass)
Returns the unique service provider for a given service and throws an exception if there
is no unique provider
|
public static <T> List<T> findServiceProviders(Class<T> klass)
klass
- service interface or classpublic static <T> T findAnyServiceProvider(Class<T> klass)
klass
- service interface or classpublic static <T> T loadAnyServiceProvider(Class<T> klass)
klass
- service interface or classNoServiceProviderException
public static <T> T loadUniqueServiceProvider(Class<T> klass)
klass
- service interface or classNoServiceProviderException
NonUniqueServiceProviderException
Copyright © 2006–2019 OPS4J - Open Participation Software for Java. All rights reserved.