Class ServiceProviderBuildItem
- java.lang.Object
-
- io.quarkus.builder.item.BuildItem
-
- io.quarkus.builder.item.MultiBuildItem
-
- io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem
-
public final class ServiceProviderBuildItem extends MultiBuildItem
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 byproviders()
for reflection (instantiation only).
-
-
Constructor Summary
Constructors Constructor Description ServiceProviderBuildItem(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static 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.List<String>
providers()
String
serviceDescriptorFile()
-
-
-
Field Detail
-
SPI_ROOT
public static final String SPI_ROOT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ServiceProviderBuildItem
public ServiceProviderBuildItem(String serviceInterfaceClassName, String... providerClassNames)
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
public 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. 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
public 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. 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 Detail
-
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
public 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.- 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
-
serviceDescriptorFile
public String serviceDescriptorFile()
- Returns:
- the resource path for the service descriptor file
-
-