Stay organized with collections
Save and categorize content based on your preferences.
ServiceLoader.Provider
public
static
interface
ServiceLoader.Provider
implements
Supplier<S>
java.util.ServiceLoader.Provider<S>
|
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.
Summary
Public methods |
abstract
S
|
get()
Returns an instance of the provider.
|
abstract
Class<? extends S>
|
type()
Returns the provider type.
|
Public methods
get
public abstract S get ()
Returns an instance of the provider.
Returns |
S |
An instance of the provider. |
Throws |
ServiceConfigurationError |
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. |
type
public abstract Class<? extends S> 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()
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 |
Class<? extends S> |
The provider type |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ServiceLoader.Provider\n\nAdded in [API level 35](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nServiceLoader.Provider\n======================\n\n\n`\npublic\nstatic\n\n\ninterface\nServiceLoader.Provider\n`\n\n\n`\n\n\nimplements\n\n`[Supplier](/reference/java/util/function/Supplier)`\u003cS\u003e\n\n\n`\n\n|---------------------------------------|\n| java.util.ServiceLoader.Provider\\\u003cS\\\u003e |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nRepresents a service provider located by `ServiceLoader`.\n\nWhen using a loader's [stream()](/reference/java/util/ServiceLoader#stream()) method\nthen the elements are of type `Provider`. This allows processing\nto select or filter on the provider class without instantiating the\nprovider.\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| ### Public methods ||\n|----------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|\n| ` abstract S` | ` `[get](/reference/java/util/ServiceLoader.Provider#get())`() ` Returns an instance of the provider. |\n| ` abstract `[Class](/reference/java/lang/Class)`\u003c? extends S\u003e` | ` `[type](/reference/java/util/ServiceLoader.Provider#type())`() ` Returns the provider type. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[java.util.function.Supplier](/reference/java/util/function/Supplier)` ` |---------------|----------------------------------------------------------------------------| | ` abstract S` | ` `[get](/reference/java/util/function/Supplier#get())`() ` Gets a result. | ||\n\nPublic methods\n--------------\n\n### get\n\nAdded in [API level 35](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract S get ()\n```\n\nReturns an instance of the provider.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----|-------------------------------------|\n| `S` | An instance of the provider. \u003cbr /\u003e |\n\n| Throws ||\n|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [ServiceConfigurationError](/reference/java/util/ServiceConfigurationError) | 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. |\n\n### type\n\nAdded in [API level 35](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract Class\u003c? extends S\u003e type ()\n```\n\nReturns the provider type. There is no guarantee that this type is\naccessible or that it has a public no-args constructor. The [get()](/reference/java/util/ServiceLoader.Provider#get()) method should be used to obtain the provider instance.\n\nWhen a module declares that the provider class is created by a\nprovider factory then this method returns the return type of its\npublic static \"`provider()`\" method.\n\n\u003cbr /\u003e\n\n| Returns ||\n|----------------------------------------------------|--------------------------|\n| [Class](/reference/java/lang/Class)`\u003c? extends S\u003e` | The provider type \u003cbr /\u003e |"]]