private void generateCleanSeparationGraph() {
StringBuilder dot = new StringBuilder("digraph G {\n");
dot.append(" rankdir=LR; node [shape=plain, fontname=\"Arial\", fontsize=10];\n\n");
Set<String> processed = new HashSet<>();
ApplicationContext current = this.startContext;
while (current != null) {
ConfigurableListableBeanFactory factory = ((ConfigurableApplicationContext) current).getBeanFactory();
for (String name : factory.getBeanDefinitionNames()) {
if (processed.add(name)) {
BeanDefinition def = factory.getBeanDefinition(name);
String color = name.toLowerCase().contains("comet") ? "#FFF9C4" :
(name.toLowerCase().contains("cpls") ? "#C8E6C9" : "#E1F5FE");
dot.append(String.format(" \"%s\" [label=<<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" BGCOLOR=\"%s\">\n", name, color));
dot.append(String.format(" <TR><TD COLSPAN=\"2\"><B>%s</B></TD></TR>\n", xmlEscape(name)));
// 1. Process standard properties
for (PropertyValue pv : def.getPropertyValues().getPropertyValues()) {
String cleanVal = extractValue(pv.getValue(), false); // FALSE: Don't resolve refs here
dot.append(" <TR><TD ALIGN=\"LEFT\">").append(xmlEscape(pv.getName())).append("</TD>");
dot.append("<TD ALIGN=\"LEFT\">").append(xmlEscape(cleanVal)).append("</TD></TR>\n");
}
// 2. NEW: Process Constructor Arguments ONLY when defining the target bean
ConstructorArgumentValues cav = def.getConstructorArgumentValues();
if (!cav.isEmpty()) {
for (Map.Entry<Integer, ConstructorArgumentValues.ValueHolder> entry : cav.getIndexedArgumentValues().entrySet()) {
String cleanVal = extractValue(entry.getValue().getValue(), false);
dot.append(" <TR><TD ALIGN=\"LEFT\"><I>arg[" + entry.getKey() + "]</I></TD>");
dot.append("<TD ALIGN=\"LEFT\">").append(xmlEscape(cleanVal)).append("</TD></TR>\n");
}
}
dot.append(" </TABLE>>];\n");
for (String dep : factory.getDependenciesForBean(name)) {
dot.append(String.format(" \"%s\" -> \"%s\";\n", name, dep));
}
}
}
current = current.getParent();
}
dot.append("}\n");
System.out.println("----- COPY START -----\n" + dot.toString() + "\n----- COPY END -----");
}
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)