Fix problems caused by changes in actuator endpoints for boot 2.0... AGAIN

This commit is contained in:
Kris De Volder
2018-01-16 12:14:22 -08:00
parent 689f9330a9
commit e700457149
3 changed files with 12 additions and 2 deletions

View File

@@ -242,13 +242,15 @@ public class SpringBootApp {
}
public String getAutoConfigReport() throws Exception {
//Boot 1.x
Object result = getActuatorDataFromAttribute("org.springframework.boot:type=Endpoint,name=autoConfigurationReportEndpoint", "Data");
if (result != null) {
String report = new ObjectMapper().writeValueAsString(result);
return report;
}
result = getActuatorDataFromOperation("org.springframework.boot:type=Endpoint,name=Conditions", "getEvaluationReport");
//Boot 2.x
result = getActuatorDataFromOperation("org.springframework.boot:type=Endpoint,name=Conditions", "applicationConditionEvaluation");
if (result != null) {
String report = new ObjectMapper().writeValueAsString(result);
return report;

View File

@@ -117,7 +117,7 @@ public class LiveBeansModel {
public LiveBeansModel parse(String json) throws Exception {
Builder model = LiveBeansModel.builder();
JSONObject mainObject = new JSONObject(json);
JSONObject beansObject = mainObject.getJSONObject("beans");
JSONObject beansObject = getBeans(mainObject);
for (String id : beansObject.keySet()) {
JSONObject beanObject = beansObject.getJSONObject(id);
LiveBean bean = parseBean(id, beanObject);
@@ -128,6 +128,14 @@ public class LiveBeansModel {
return model.build();
}
private JSONObject getBeans(JSONObject mainObject) {
JSONObject beans = mainObject.optJSONObject("beans");
if (beans==null) {
beans = mainObject.getJSONObject("contexts").getJSONObject("application").getJSONObject("beans");
}
return beans;
}
private LiveBean parseBean(String id, JSONObject beansJSON) {
String type = beansJSON.optString("type");
String scope = beansJSON.optString("scope");