91
91
*/
92
92
public class CloudFoundryVcapEnvironmentPostProcessor implements EnvironmentPostProcessor , Ordered {
93
93
94
- private static final String VCAP_APPLICATION = "VCAP_APPLICATION" ;
95
-
96
- private static final String VCAP_SERVICES = "VCAP_SERVICES" ;
97
-
98
94
private final Log logger ;
99
95
100
96
// Before ConfigDataEnvironmentPostProcessor so values there can use these
@@ -126,12 +122,12 @@ public void postProcessEnvironment(ConfigurableEnvironment environment, SpringAp
126
122
addWithPrefix (properties , getPropertiesFromApplication (environment , jsonParser ), "vcap.application." );
127
123
addWithPrefix (properties , getPropertiesFromServices (environment , jsonParser ), "vcap.services." );
128
124
MutablePropertySources propertySources = environment .getPropertySources ();
125
+ PropertiesPropertySource vcapSource = new PropertiesPropertySource ("vcap" , properties );
129
126
if (propertySources .contains (CommandLinePropertySource .COMMAND_LINE_PROPERTY_SOURCE_NAME )) {
130
- propertySources .addAfter (CommandLinePropertySource .COMMAND_LINE_PROPERTY_SOURCE_NAME ,
131
- new PropertiesPropertySource ("vcap" , properties ));
127
+ propertySources .addAfter (CommandLinePropertySource .COMMAND_LINE_PROPERTY_SOURCE_NAME , vcapSource );
132
128
}
133
129
else {
134
- propertySources .addFirst (new PropertiesPropertySource ( "vcap" , properties ) );
130
+ propertySources .addFirst (vcapSource );
135
131
}
136
132
}
137
133
}
@@ -146,7 +142,7 @@ private void addWithPrefix(Properties properties, Properties other, String prefi
146
142
private Properties getPropertiesFromApplication (Environment environment , JsonParser parser ) {
147
143
Properties properties = new Properties ();
148
144
try {
149
- String property = environment .getProperty (VCAP_APPLICATION , "{}" );
145
+ String property = environment .getProperty (" VCAP_APPLICATION" , "{}" );
150
146
Map <String , Object > map = parser .parseMap (property );
151
147
extractPropertiesFromApplication (properties , map );
152
148
}
@@ -159,7 +155,7 @@ private Properties getPropertiesFromApplication(Environment environment, JsonPar
159
155
private Properties getPropertiesFromServices (Environment environment , JsonParser parser ) {
160
156
Properties properties = new Properties ();
161
157
try {
162
- String property = environment .getProperty (VCAP_SERVICES , "{}" );
158
+ String property = environment .getProperty (" VCAP_SERVICES" , "{}" );
163
159
Map <String , Object > map = parser .parseMap (property );
164
160
extractPropertiesFromServices (properties , map );
165
161
}
0 commit comments