You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/03/13 16:29:08 UTC
(camel) 06/06: CAMEL-18090: camel-main - Loading properties with profiles for prod/dev/test
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main-profile
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 5972fe23e7fe9fddace9133160749c48b46e7dd0
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Mar 13 17:25:59 2024 +0100
CAMEL-18090: camel-main - Loading properties with profiles for prod/dev/test
---
.../src/main/java/org/apache/camel/main/BaseMainSupport.java | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index 52065f24cde..da315a53a79 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -363,9 +363,20 @@ public abstract class BaseMainSupport extends BaseService {
if (pc.getLocations().isEmpty()) {
String locations = propertyPlaceholderLocations;
if (locations == null) {
+ // ENV/SYS takes precedence, then java configured value
String profile = MainHelper.lookupPropertyFromSysOrEnv(MainConstants.PROFILE)
.orElse(mainConfigurationProperties.getProfile());
+ if (profile == null) {
+ // fallback to check if application.properties has a profile
+ Properties prop = new Properties();
+ try (InputStream is
+ = ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, "application.properties")) {
+ prop.load(is);
+ }
+ profile = prop.getProperty("camel.main.profile");
+ }
if (profile != null) {
+ mainConfigurationProperties.setProfile(profile);
String loc = profilePropertyPlaceholderLocation(profile);
defaultPropertyPlaceholderLocation = loc + "," + defaultPropertyPlaceholderLocation;
}