File tree 3 files changed +39
-5
lines changed
main/java/io/helidon/config/mp
test/java/io/helidon/config/mp
3 files changed +39
-5
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright (c) 2020, 2021 Oracle and/or its affiliates.
2
+ * Copyright (c) 2020, 2024 Oracle and/or its affiliates.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
25
25
26
26
import org .eclipse .microprofile .config .spi .ConfigSource ;
27
27
28
- @ Priority (300 )
28
+ @ Priority (MpEnvironmentVariablesSource . MY_DEFAULT_ORDINAL )
29
29
class MpEnvironmentVariablesSource implements ConfigSource {
30
+ static final int MY_DEFAULT_ORDINAL = 300 ;
30
31
private static final Pattern DISALLOWED_CHARS = Pattern .compile ("[^a-zA-Z0-9_]" );
31
32
private static final String UNDERSCORE = "_" ;
32
33
@@ -71,6 +72,16 @@ public String getValue(String propertyName) {
71
72
}).value ;
72
73
}
73
74
75
+ @ Override
76
+ public int getOrdinal () {
77
+ String configOrdinal = getValue (CONFIG_ORDINAL );
78
+ if (configOrdinal == null ) {
79
+ return MY_DEFAULT_ORDINAL ;
80
+ } else {
81
+ return ConfigSource .super .getOrdinal ();
82
+ }
83
+ }
84
+
74
85
@ Override
75
86
public String getName () {
76
87
return "Environment Variables" ;
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright (c) 2020, 2021 Oracle and/or its affiliates.
2
+ * Copyright (c) 2020, 2024 Oracle and/or its affiliates.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
26
26
27
27
import org .eclipse .microprofile .config .spi .ConfigSource ;
28
28
29
- @ Priority (400 )
29
+ @ Priority (MpSystemPropertiesSource . MY_DEFAULT_ORDINAL )
30
30
class MpSystemPropertiesSource implements ConfigSource {
31
+ static final int MY_DEFAULT_ORDINAL = 400 ;
31
32
private final Properties props ;
32
33
33
34
MpSystemPropertiesSource () {
@@ -58,6 +59,16 @@ public String getName() {
58
59
return "System Properties" ;
59
60
}
60
61
62
+ @ Override
63
+ public int getOrdinal () {
64
+ String configOrdinal = getValue (CONFIG_ORDINAL );
65
+ if (configOrdinal == null ) {
66
+ return MY_DEFAULT_ORDINAL ;
67
+ } else {
68
+ return ConfigSource .super .getOrdinal ();
69
+ }
70
+ }
71
+
61
72
@ Override
62
73
public String toString () {
63
74
return getName () + " (" + getOrdinal () + ")" ;
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright (c) 2020, 2022 Oracle and/or its affiliates.
2
+ * Copyright (c) 2020, 2024 Oracle and/or its affiliates.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -107,6 +107,18 @@ void testMpConfigSourcesNullConfig() {
107
107
assertThat (npe .getMessage (), is ("Config cannot be null" ));
108
108
}
109
109
110
+ @ Test
111
+ void testSystemPropertiesConfigSourceDefaultOrdinal () {
112
+ org .eclipse .microprofile .config .spi .ConfigSource configSource = MpConfigSources .systemProperties ();
113
+ assertThat (configSource .getOrdinal (), is (400 ));
114
+ }
115
+
116
+ @ Test
117
+ void testEnvironmentVariablesConfigSourceDefaultOrdinal () {
118
+ org .eclipse .microprofile .config .spi .ConfigSource configSource = MpConfigSources .environmentVariables ();
119
+ assertThat (configSource .getOrdinal (), is (300 ));
120
+ }
121
+
110
122
private static final class NodeImpl implements ConfigSource , NodeConfigSource {
111
123
private static final String DESCRIPTION = "node-unit-test" ;
112
124
private static final String KEY = "key" ;
You can’t perform that action at this time.
0 commit comments