Class ServiceProviderBuildItem
java.lang.Object
io.quarkus.builder.item.BuildItem
io.quarkus.builder.item.MultiBuildItem
io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem
Represents a Service Provider registration.
When processed, it embeds the service interface descriptor (META-INF/services/...) in the native image
and registers the classes returned by
providers()
for reflection (instantiation only).-
Field Summary
-
Constructor Summary
ConstructorDescriptionServiceProviderBuildItem
(String serviceInterfaceClassName, String... providerClassNames) Registers the specified service interface descriptor to be embedded and allow reflection (instantiation only) of the specified provider classes.ServiceProviderBuildItem
(String serviceInterfaceClassName, Collection<String> providers) Registers the specified service interface descriptor to be embedded and allow reflection (instantiation only) of the specified provider classes.ServiceProviderBuildItem
(String serviceInterfaceClassName, List<String> providers) Registers the specified service interface descriptor to be embedded and allow reflection (instantiation only) of the specified provider classes. -
Method Summary
Modifier and TypeMethodDescriptionstatic ServiceProviderBuildItem
allProviders
(String serviceInterfaceClassName, Path serviceInterfaceDescriptorFile) Creates and returns aServiceProviderBuildItem
for theserviceInterfaceClassName
by including all the providers that are listed in the service interface descriptor file.static ServiceProviderBuildItem
allProvidersFromClassPath
(String serviceInterfaceClassName) Creates and returns a newServiceProviderBuildItem
for the givenserviceInterfaceClassName
by including all the providers that are listed in service interface descriptor files"META-INF/services/" + serviceInterfaceClassName
findable in the Context Class Loader of the current thread.
-
Field Details
-
SPI_ROOT
- See Also:
-
-
Constructor Details
-
ServiceProviderBuildItem
Registers the specified service interface descriptor to be embedded and allow reflection (instantiation only) of the specified provider classes. Note that the service interface descriptor file has to exist and match the list of specified provider class names.- Parameters:
serviceInterfaceClassName
- the interface whose service interface descriptor file we want to embedproviderClassNames
- the list of provider class names that must already be mentioned in the file
-
ServiceProviderBuildItem
Registers the specified service interface descriptor to be embedded and allow reflection (instantiation only) of the specified provider classes. Note that the service interface descriptor file has to exist and match the list of specified provider class names.- Parameters:
serviceInterfaceClassName
- the interface whose service interface descriptor file we want to embedproviders
- a collection of provider class names that must already be mentioned in the file
-
ServiceProviderBuildItem
Registers the specified service interface descriptor to be embedded and allow reflection (instantiation only) of the specified provider classes. Note that the service interface descriptor file has to exist and match the list of specified provider class names.- Parameters:
serviceInterfaceClassName
- the interface whose service interface descriptor file we want to embedproviders
- the list of provider class names that must already be mentioned in the file
-
-
Method Details
-
allProviders
public static ServiceProviderBuildItem allProviders(String serviceInterfaceClassName, Path serviceInterfaceDescriptorFile) throws IOException Creates and returns aServiceProviderBuildItem
for theserviceInterfaceClassName
by including all the providers that are listed in the service interface descriptor file.- Parameters:
serviceInterfaceClassName
- the interface whose service interface descriptor file we want to embedserviceInterfaceDescriptorFile
- the path to the service interface descriptor file- Returns:
- Throws:
IOException
-
allProvidersFromClassPath
Creates and returns a newServiceProviderBuildItem
for the givenserviceInterfaceClassName
by including all the providers that are listed in service interface descriptor files"META-INF/services/" + serviceInterfaceClassName
findable in the Context Class Loader of the current thread.- Parameters:
serviceInterfaceClassName
- the interface whose service interface descriptor file we want to embed- Returns:
- a new
ServiceProviderBuildItem
- Throws:
RuntimeException
- wrapping anyIOException
s thrown when accessing class path resources
-
providers
- Returns:
- an immutable
List
of provider class names
-
serviceDescriptorFile
- Returns:
- the resource path for the service descriptor file
-