|
4 | 4 |
|
5 | 5 | package org.lfenergy.compas.scl.data.repository.postgresql; |
6 | 6 |
|
7 | | -import io.quarkus.arc.DefaultBean; |
8 | | -import io.quarkus.arc.lookup.LookupIfProperty; |
9 | 7 | import jakarta.enterprise.context.ApplicationScoped; |
10 | 8 | import jakarta.enterprise.inject.Produces; |
| 9 | +import org.apache.logging.log4j.LogManager; |
| 10 | +import org.apache.logging.log4j.Logger; |
| 11 | +import org.eclipse.microprofile.config.inject.ConfigProperty; |
11 | 12 | import org.lfenergy.compas.scl.data.repository.CompasSclDataRepository; |
12 | 13 |
|
13 | 14 | import javax.sql.DataSource; |
14 | 15 |
|
15 | 16 | public class CompasSclDataPostgreSQLRepositoryConfiguration { |
16 | 17 |
|
| 18 | + private static final Logger LOGGER = LogManager.getLogger(CompasSclDataPostgreSQLRepositoryConfiguration.class); |
| 19 | + |
| 20 | + @ConfigProperty(name = "compas.scl-data-service.features.soft-delete-enabled", defaultValue = "false") |
| 21 | + private boolean softDeleteEnabled; |
| 22 | + |
17 | 23 | @Produces |
18 | 24 | @ApplicationScoped |
19 | | - @LookupIfProperty(name = "compas.scl-data-service.features.soft-delete-enabled", stringValue = "true") |
20 | 25 | CompasSclDataRepository softDeleteCompasSclDataPostgreSQLRepository(DataSource dataSource) { |
| 26 | + if (!softDeleteEnabled) { |
| 27 | + LOGGER.warn("Soft delete feature is disabled, using default repository."); |
| 28 | + return new CompasSclDataPostgreSQLRepository(dataSource); |
| 29 | + } |
| 30 | + LOGGER.info("Soft delete feature is enabled. Using SoftDeleteCompasSclDataPostgreSQLRepository."); |
21 | 31 | return new SoftDeleteCompasSclDataPostgreSQLRepository(dataSource); |
22 | 32 | } |
23 | | - |
24 | | - @Produces |
25 | | - @ApplicationScoped |
26 | | - @DefaultBean |
27 | | - CompasSclDataRepository defaultCompasSclDataPostgreSQLRepository(DataSource dataSource) { |
28 | | - return new CompasSclDataPostgreSQLRepository(dataSource); |
29 | | - } |
30 | 33 | } |
0 commit comments