forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make DataSource beans application-scoped
So that we'll be able to postpone initialization to first access in some cases, instead of doing it on startup. This could be useful in particular for deactivated datasources: we don't want to initialize those on startup, but we do want them to fail on first use. An alternative would have been to represent deactivated datasources with a custom implementation of AgroalDataSource, like we currently do with UnconfiguredDataSource, but that solution has serious problems, in particular when we "forget" to implement some methods: see quarkusio#36666
- Loading branch information
Showing
5 changed files
with
60 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
extensions/agroal/deployment/src/test/java/io/quarkus/agroal/test/EagerStartupTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.quarkus.agroal.test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.agroal.runtime.DataSources; | ||
import io.quarkus.arc.Arc; | ||
import io.quarkus.datasource.common.runtime.DataSourceUtil; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
/** | ||
* Check that datasources are created eagerly on application startup. | ||
* <p> | ||
* This has always been the case historically, so we want to keep it that way. | ||
*/ | ||
public class EagerStartupTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withConfigurationResource("base.properties"); | ||
|
||
@Test | ||
public void shouldStartEagerly() { | ||
assertThat(Arc.container().instance(DataSources.class).get() | ||
.isDataSourceCreated(DataSourceUtil.DEFAULT_DATASOURCE_NAME)) | ||
.isTrue(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters