ServiceLoader.Provider (Java SE 9 & JDK 9 ) (original) (raw)
- Type Parameters:
S
- The service type
All Superinterfaces:[Supplier](../../java/util/function/Supplier.html "interface in java.util.function")<S>
Enclosing class:
ServiceLoader<S>
public static interface ServiceLoader.Provider
extends Supplier
Represents a service provider located by ServiceLoader
.
When using a loader's stream() method then the elements are of type Provider
. This allows processing to select or filter on the provider class without instantiating the provider.
Since:
9
Method Summary
All Methods Instance Methods Abstract Methods
Modifier and Type Method Description S get() Returns an instance of the provider. Class<? extends S> type() Returns the provider type. Method Detail
* #### type [Class](../../java/lang/Class.html "class in java.lang")<? extends [S](../../java/util/ServiceLoader.Provider.html "type parameter in ServiceLoader.Provider")> type() Returns the provider type. There is no guarantee that this type is accessible or that it has a public no-args constructor. The [get()](../../java/util/ServiceLoader.Provider.html#get--) method should be used to obtain the provider instance. When a module declares that the provider class is created by a provider factory then this method returns the return type of its public static "`provider()`" method. Returns: The provider type * #### get [S](../../java/util/ServiceLoader.Provider.html "type parameter in ServiceLoader.Provider") get() Returns an instance of the provider. Specified by: `[get](../../java/util/function/Supplier.html#get--)` in interface `[Supplier](../../java/util/function/Supplier.html "interface in java.util.function")<[S](../../java/util/ServiceLoader.Provider.html "type parameter in ServiceLoader.Provider")>` Returns: An instance of the provider. Throws: `[ServiceConfigurationError](../../java/util/ServiceConfigurationError.html "class in java.util")` \- If the service provider cannot be instantiated, or in the case of a provider factory, the public static "`provider()`" method returns `null` or throws an error or exception. The `ServiceConfigurationError` will carry an appropriate cause where possible.
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2017, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.