forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make PID, application version and title available in the environment
Adds the following new properties: - spring.application.pid - spring.application.version - spring.application.title Refactors the ResourceBanner and the structured logging support to use the new properties.
- Loading branch information
1 parent
67bae52
commit 4d5e20c
Showing
22 changed files
with
282 additions
and
130 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
59 changes: 59 additions & 0 deletions
59
...ect/spring-boot/src/main/java/org/springframework/boot/ApplicationInfoPropertySource.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,59 @@ | ||
/* | ||
* Copyright 2012-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.boot; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.springframework.boot.system.ApplicationPid; | ||
import org.springframework.boot.system.ApplicationTitle; | ||
import org.springframework.boot.system.ApplicationVersion; | ||
import org.springframework.core.env.MapPropertySource; | ||
import org.springframework.core.env.PropertySource; | ||
|
||
/** | ||
* {@link PropertySource} which provides information about the application, like the | ||
* title, the PID or the version. | ||
* | ||
* @author Moritz Halbritter | ||
*/ | ||
class ApplicationInfoPropertySource extends MapPropertySource { | ||
|
||
static final String NAME = "applicationInfo"; | ||
|
||
ApplicationInfoPropertySource(Class<?> mainClass) { | ||
super(NAME, getProperties(mainClass)); | ||
} | ||
|
||
private static Map<String, Object> getProperties(Class<?> mainClass) { | ||
Map<String, Object> result = new HashMap<>(); | ||
ApplicationVersion applicationVersion = new ApplicationVersion(mainClass); | ||
if (applicationVersion.isAvailable()) { | ||
result.put("spring.application.version", applicationVersion.asString()); | ||
} | ||
ApplicationTitle applicationTitle = new ApplicationTitle(mainClass); | ||
if (applicationTitle.isAvailable()) { | ||
result.put("spring.application.title", applicationTitle.asString()); | ||
} | ||
ApplicationPid applicationPid = new ApplicationPid(); | ||
if (applicationPid.isAvailable()) { | ||
result.put("spring.application.pid", applicationPid.asLong()); | ||
} | ||
return result; | ||
} | ||
|
||
} |
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
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
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
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
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
Oops, something went wrong.