Nov 3rd, 2011, 11:54 AM
Print out "effective configuration" at runtime
Does anyone know of a tool which can print out the "effective configuration" for a spring container at runtime?
What I'm wanting is something that will reconcile all of the various wirings that have been processed by a container and display them as one giant config file (or diagram, or whatever)...
A coworker and I have considered writing this, but would hate to duplicate effort...
Nov 8th, 2011, 11:10 PM
Do you mean like the bean graphs that STS and IntelliJ can create from the .xml files?
In STS you can open up a Spring xml file, and if you look at the bottom of the file, you will see some tabs. The one on the right should say "Bean Graph" this will create a bean visual graph of the beans inside that xml file. For graphs of multiple xml files combined. IN STS you create what is called a config set. You create it by using the Spring Explorer view. In that view, select your project - right click and choose properties. When the properties window pops up, on the right side there are two tabs, one says config files, the other says config sets. You can add your xml files to the config files, then go to the config sets tab and create a config set, give it a name and select the xml files in the check box list below it. After you create the config set. You can now right click on the config set in the Spring explorer and select "show dependency graph" and it will show you a visual graph of all the beans in all the config files in your config set and lines between all the dependencies.
Is that what you were looking for?
Nov 9th, 2011, 12:55 AM
That sounds similar to what I'm looking for (though I'm not using STS); the difference would be to produce a runtime printout of the bean configuration and/or dependency graph.
I don't know if the STS tabs you're talking about also include all of the @Autowired fields of classes found during component-scan and the beanswith autowire="..." attribute, but that's probably the part I would care about the most...I'm guessing it doesn't cover these things, as some could depend on the classpath at runtime.
A good analog would be the "effective pom" display in Maven, which shows (among other things) the effective versions, scopes, etc. of all build-time dependencies that were resolved during your particular build session.
Nov 9th, 2011, 06:05 PM
That is correct @Autowired does not show up in the bean dependency graph.
Nov 14th, 2011, 08:36 AM
It does in IntelliJ... ;-) IntelliJ's Spring support recognizes and resolves your auto-wired dependencies (or the lack of any implementations in the app context to satisfy the declared auto-wiring, which would be marked as a warning or error - depending on your inspections config - in your editor.) This is done on the fly, in your editor/project, no need to run the application to test the dependencies. Needless to say, you will see all your auto-wired dependencies in the application context graph representation tab. IntelliJ will also instantly report any conflicts and ambiguities/multiple implementations of an auto-wired dependency that requires a single instance to be present. It makes it easy to decide whether you need to add a qualifier to the @Autowired annotation, or switch to an explicit injection.
Last edited by constv; Nov 14th, 2011 at 08:48 AM.
Tags for this Thread