Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting CDI SPI implementations repeatedly #696

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,11 @@ private static void discoverFactories() {
*
* @param instance a {@link BuildServices} instance that should be used, must not be {@code null}
* @throws IllegalArgumentException if the provided argument is null
* @throws IllegalStateException if the {@link BuildServices} are already set
*/
public static void setBuildServices(BuildServices instance) {
if (instance == null) {
throw new IllegalArgumentException("BuildServices instance must not be null");
}
if (configuredBuildServices == null) {
configuredBuildServices = instance;
} else {
throw new IllegalStateException("BuildServices cannot be set repeatedly. Existing BuildServices are " + configuredBuildServices);
}
configuredBuildServices = instance;
}
}
9 changes: 2 additions & 7 deletions api/src/main/java/jakarta/enterprise/inject/spi/CDI.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,14 @@ private static boolean checkProvider(CDIProvider c) {
* </p>
*
* @param provider the provider to use
* @throws IllegalStateException if the {@link CDIProvider} is already set
* @throws IllegalArgumentException if the provided argument is null
*/
public static void setCDIProvider(CDIProvider provider) {
if (provider == null) {
throw new IllegalArgumentException("CDIProvider must not be null");
}
if (configuredProvider == null) {
providerSetManually = true;
configuredProvider = provider;
} else {
throw new IllegalStateException("CDIProvider cannot be set repeatedly. Existing provider is " + configuredProvider);
}
providerSetManually = true;
configuredProvider = provider;
}

private static void findAllProviders() {
Expand Down