Skip to content

Commit

Permalink
Fix beans infomation lost parentId (#1319)
Browse files Browse the repository at this point in the history
Signed-off-by: JermaineHua <[email protected]>
  • Loading branch information
CrazyHZM authored May 14, 2024
1 parent 480314a commit b78f29d
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,33 @@ public IsleBeansEndpoint(ConfigurableApplicationContext context,
@Override
public BeansEndpoint.BeansDescriptor beans() {
BeansEndpoint.BeansDescriptor beansDescriptor = super.beans();
Map<String, BeansEndpoint.ContextBeansDescriptor> moduleApplicationContexts = getModuleApplicationContexts(applicationRuntimeModel);
String springParentId = null;
for (Map.Entry<String, ContextBeansDescriptor> entry : beansDescriptor.getContexts()
.entrySet()) {
if (entry.getValue().getParentId() == null) {
springParentId = entry.getKey();
break;
}
}

Map<String, BeansEndpoint.ContextBeansDescriptor> moduleApplicationContexts = getModuleApplicationContexts(
applicationRuntimeModel, springParentId);
beansDescriptor.getContexts().putAll(moduleApplicationContexts);
return beansDescriptor;
}

private Map<String, BeansEndpoint.ContextBeansDescriptor> getModuleApplicationContexts(ApplicationRuntimeModel applicationRuntimeModel) {
private Map<String, BeansEndpoint.ContextBeansDescriptor> getModuleApplicationContexts(ApplicationRuntimeModel applicationRuntimeModel,String springParentId) {
Map<String, BeansEndpoint.ContextBeansDescriptor> contexts = new HashMap<>();
List<DeploymentDescriptor> installedModules = applicationRuntimeModel.getInstalled();
installedModules.forEach(descriptor -> {
ApplicationContext applicationContext = descriptor.getApplicationContext();
String parentId = descriptor.getSpringParent();
if (parentId == null){
parentId = springParentId;
}
if (applicationContext instanceof ConfigurableApplicationContext) {
BeansEndpoint.ContextBeansDescriptor contextBeans = describing((ConfigurableApplicationContext) applicationContext,
descriptor.getSpringParent());
parentId);
if (contextBeans != null) {
contexts.put(descriptor.getModuleName(), contextBeans);
}
Expand Down

0 comments on commit b78f29d

Please sign in to comment.