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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionServiceProviderBuildItem(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 ServiceProviderBuildItemallProviders(String serviceInterfaceClassName, Path serviceInterfaceDescriptorFile) Creates and returns aServiceProviderBuildItemfor theserviceInterfaceClassNameby including all the providers that are listed in the service interface descriptor file.static ServiceProviderBuildItemallProvidersFromClassPath(String serviceInterfaceClassName) Creates and returns a newServiceProviderBuildItemfor the givenserviceInterfaceClassNameby including all the providers that are listed in service interface descriptor files"META-INF/services/" + serviceInterfaceClassNamefindable in the Context Class Loader of the current thread.static Collection<ServiceProviderBuildItem>allProvidersOfDependencies(Collection<io.quarkus.maven.dependency.ResolvedDependency> dependencies, Collection<io.quarkus.maven.dependency.ArtifactCoords> artifactCoordinatesCollection) Creates a newCollectionofServiceProviderBuildItems for the selected artifacts.static Collection<ServiceProviderBuildItem>allProvidersOfDependency(Collection<io.quarkus.maven.dependency.ResolvedDependency> dependencies, io.quarkus.maven.dependency.ArtifactCoords artifactCoordinates) Creates a newCollectionofServiceProviderBuildItems for the selected artifact.
-
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 aServiceProviderBuildItemfor theserviceInterfaceClassNameby 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 newServiceProviderBuildItemfor the givenserviceInterfaceClassNameby including all the providers that are listed in service interface descriptor files"META-INF/services/" + serviceInterfaceClassNamefindable 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 anyIOExceptions thrown when accessing class path resources
-
allProvidersOfDependency
public static Collection<ServiceProviderBuildItem> allProvidersOfDependency(Collection<io.quarkus.maven.dependency.ResolvedDependency> dependencies, io.quarkus.maven.dependency.ArtifactCoords artifactCoordinates) Creates a newCollectionofServiceProviderBuildItems for the selected artifact. It includes all the providers, that are contained in all the service interface descriptor files defined in"META-INF/services/"in the selected artifact.- Parameters:
dependencies- the resolved dependencies of the buildartifactCoordinates- the coordinates of the artifact containing the service definitions- Returns:
- a
CollectionofServiceProviderBuildItems containing all the found service providers
-
allProvidersOfDependencies
public static Collection<ServiceProviderBuildItem> allProvidersOfDependencies(Collection<io.quarkus.maven.dependency.ResolvedDependency> dependencies, Collection<io.quarkus.maven.dependency.ArtifactCoords> artifactCoordinatesCollection) Creates a newCollectionofServiceProviderBuildItems for the selected artifacts. It includes all the providers, that are contained in all the service interface descriptor files defined in"META-INF/services/"in all the selected artifacts.- Parameters:
dependencies- the resolved dependencies of the buildartifactCoordinatesCollection- aCollectionof coordinates of the artifacts containing the service definitions- Returns:
- a
CollectionofServiceProviderBuildItems containing all the found service providers
-
providers
- Returns:
- an immutable
Listof provider class names
-
serviceDescriptorFile
- Returns:
- the resource path for the service descriptor file
-