-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load Profile Sources before Factories so the profile values are avail…
…able in the Factory context (#771)
- Loading branch information
Showing
6 changed files
with
193 additions
and
67 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
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
20 changes: 20 additions & 0 deletions
20
implementation/src/main/java/io/smallrye/config/ProfileConfigSourceFactory.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,20 @@ | ||
package io.smallrye.config; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.eclipse.microprofile.config.spi.ConfigSource; | ||
|
||
interface ProfileConfigSourceFactory extends ConfigSourceFactory { | ||
@Override | ||
default Iterable<ConfigSource> getConfigSources(final ConfigSourceContext context) { | ||
final List<String> profiles = context.getProfiles(); | ||
if (profiles.isEmpty()) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
return getProfileConfigSources(profiles); | ||
} | ||
|
||
Iterable<ConfigSource> getProfileConfigSources(final List<String> profiles); | ||
} |
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
30 changes: 30 additions & 0 deletions
30
implementation/src/main/java/io/smallrye/config/SmallRyeConfigSourceContext.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,30 @@ | ||
package io.smallrye.config; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
class SmallRyeConfigSourceContext implements ConfigSourceContext { | ||
private final ConfigSourceInterceptorContext context; | ||
private final List<String> profiles; | ||
|
||
public SmallRyeConfigSourceContext(final ConfigSourceInterceptorContext context, final List<String> profiles) { | ||
this.context = context; | ||
this.profiles = profiles; | ||
} | ||
|
||
@Override | ||
public ConfigValue getValue(final String name) { | ||
ConfigValue value = context.proceed(name); | ||
return value != null ? value : ConfigValue.builder().withName(name).build(); | ||
} | ||
|
||
@Override | ||
public List<String> getProfiles() { | ||
return profiles; | ||
} | ||
|
||
@Override | ||
public Iterator<String> iterateNames() { | ||
return context.iterateNames(); | ||
} | ||
} |
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