Spring Java Configuration

I personally think that the Java configuration option for Spring is a very clever move of Rod and Co. Since reading Rod’s post and playing around with the new configuration approach, I thought it would be very nice if Spring IDE could bring the two worlds-XML and Java configuration-together and seamlessly support the user with content assist, navigation support and graphical visualization of bean definitions across both configuration styles.

Today I implemented an extension prototype for Spring IDE’s internal bean definition parsing to see if it is possible to support the annotation style. Thanks to Torsten’s core abstraction on top of Spring’s bean definitions and Eclipse’ internal Java model, I was able to parse the required meta information from a Java class which is annotated with @Configuration.

The code is not meant to be production ready, but serves as a proof-of-concept for us.

Above you can see an sample @Configuration class that defines three Spring beans: stefanie, rod, house The annotation-style beans are decorated with an @ icon in the Spring Beans view.

By leveraging Eclipse’ AST support I was able to parse the dependencies between different Spring beans from the Java code. For example the expression person.setHouse(house()); defines a dependency between the person and house bean. Even the reference to XML-configured bean-resolved by person.setHouse((House) getBean("company"));-can be extracted from the source code.

Therefore Spring IDE is able to bring up a Beans Graph for the sample that outlines the dependencies between Java and XML-configured beans.

Let me know what you think and if you want to see that support in Spring IDE 2.0. I will provide a download of the prototpye to play around with after some more testing.

5 Responses to “Spring Java Configuration”


  1. 1 Konan Apr 22nd, 2007 at 16:10 Quote

    I definitely like the idea. I would like to have these tools available by default in both Spring and Spring IDE (both projects helping the other’s adoption).

  2. 2 Konan Apr 22nd, 2007 at 16:18 Quote

    Where can I download it?

  3. 3 Christian Apr 22nd, 2007 at 16:28 Quote

    I’m currently working to get the Spring JavaConfig support into the 2.0 code stream. If everything goes well, you will see the support in one of the Spring IDE 2.0 nighty builds in a couple of days. We are planning to add preliminary support into Spring IDE 2.0 final.

    There are some outstanding changes that need to be implemented before I can move on. Furthermore I have to consider Costin’s latest changes.

  4. 4 Christina joseph Aug 9th, 2007 at 10:36 Quote

    This is a little bit different as it relies in an external Java class that configures groups of beans together. It resembles a lot to the XML configuration. IMO .

  1. 1 Support for Spring JavaConfig at Spring IDE Blog Pingback on May 18th, 2007 at 17:50

Leave a Reply

Quote selected text