16
16
17
17
package org .springframework .boot .actuate .autoconfigure .web .server ;
18
18
19
+ import java .util .Map ;
20
+
19
21
import org .springframework .beans .factory .SmartInitializingSingleton ;
20
22
import org .springframework .boot .actuate .autoconfigure .web .ManagementContextFactory ;
21
23
import org .springframework .boot .actuate .autoconfigure .web .ManagementContextType ;
@@ -109,29 +111,33 @@ static ChildManagementContextInitializer childManagementContextInitializer(
109
111
110
112
}
111
113
114
+ /**
115
+ * {@link EnumerablePropertySource} providing {@code local.management.port} support.
116
+ */
112
117
static class LocalManagementPortPropertySource extends EnumerablePropertySource <Object >
113
118
implements OriginLookup <String > {
114
119
115
- private static final String [] PROPERTIES = { "local.management.port" };
120
+ private static final Map <String , String > PROPERTY_MAPPINGS = Map .of ("local.management.port" ,
121
+ "local.server.port" );
122
+
123
+ private static final String [] PROPERTY_NAMES = PROPERTY_MAPPINGS .keySet ().toArray (String []::new );
116
124
117
- private final ConfigurableEnvironment environment ;
125
+ private final Environment environment ;
118
126
119
- LocalManagementPortPropertySource (ConfigurableEnvironment environment ) {
127
+ LocalManagementPortPropertySource (Environment environment ) {
120
128
super ("Management Server" );
121
129
this .environment = environment ;
122
130
}
123
131
124
132
@ Override
125
133
public String [] getPropertyNames () {
126
- return PROPERTIES ;
134
+ return PROPERTY_NAMES ;
127
135
}
128
136
129
137
@ Override
130
138
public Object getProperty (String name ) {
131
- if ("local.management.port" .equals (name )) {
132
- return this .environment .getProperty ("local.server.port" );
133
- }
134
- return null ;
139
+ String mapped = PROPERTY_MAPPINGS .get (name );
140
+ return (mapped != null ) ? this .environment .getProperty (mapped ) : null ;
135
141
}
136
142
137
143
@ Override
@@ -143,6 +149,7 @@ public Origin getOrigin(String key) {
143
149
public boolean isImmutable () {
144
150
return true ;
145
151
}
152
+
146
153
}
147
154
148
155
}
0 commit comments