This repository has been archived by the owner on Jul 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from ralf-ueberfuhr-ars/feature/config
Make initializer configurable.
- Loading branch information
Showing
5 changed files
with
135 additions
and
4 deletions.
There are no files selected for viewing
52 changes: 49 additions & 3 deletions
52
...provider/src/main/java/de/schulung/sample/quarkus/domain/CustomersServiceInitializer.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
39 changes: 39 additions & 0 deletions
39
...ain/java/de/schulung/sample/quarkus/further/mpconfig/ConfigurationPropertiesProvider.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,39 @@ | ||
package de.schulung.sample.quarkus.further.mpconfig; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.inject.Produces; | ||
import jakarta.inject.Qualifier; | ||
import lombok.Getter; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@ApplicationScoped | ||
public class ConfigurationPropertiesProvider { | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ | ||
ElementType.TYPE, | ||
ElementType.FIELD, | ||
ElementType.METHOD, | ||
ElementType.PARAMETER | ||
}) | ||
@Qualifier | ||
public @interface InitialCustomerName { | ||
} | ||
|
||
@ConfigProperty( | ||
name = "customers.initialization.sample.name", | ||
defaultValue = "John Doe" | ||
) | ||
@Getter(onMethod_ = { | ||
@Produces, | ||
@InitialCustomerName | ||
}) | ||
String initialCustomerName; | ||
|
||
|
||
} |
25 changes: 25 additions & 0 deletions
25
.../src/main/java/de/schulung/sample/quarkus/further/mpconfig/ConfigurationTestResource.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,25 @@ | ||
package de.schulung.sample.quarkus.further.mpconfig; | ||
|
||
import de.schulung.sample.quarkus.further.mpconfig.ConfigurationPropertiesProvider.InitialCustomerName; | ||
import io.quarkus.arc.profile.UnlessBuildProfile; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
@UnlessBuildProfile("prod") | ||
@Path("/config-properties") | ||
public class ConfigurationTestResource { | ||
|
||
@Inject | ||
@InitialCustomerName | ||
String customerName; | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String answer() { | ||
return "Initial customer name: " + customerName; | ||
} | ||
|
||
} |
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