Published by Christian 6 months, 3 weeks ago
in Journal and Noteworthy.
With the imminent release of Spring IDE 2.0.3 we are going to introduce two new features that I’m going to outline in this post.
Support for the import Element
Probably the most requested feature to add to Spring IDE is supporting <import /> elements in Spring configuration files. Up to now imports have been ignored by Spring IDE’s internal parser due to some limitations we had with the way Spring Core handled the processing of imports and the non-trivial task of porting scanning facilities for the classpath*: protocol over to the Eclipse OSGi runtime.

With Spring IDE 2.0.3 which will be released today we finally managed to add support for imports. So after upgrading to 2.0.3 you will eventually notice a new setting on the preference page that allows to explicitly enable the import support (see screenshot below).

After enabling the import support you might end up with error messages like: Overrides another bean ‘X’ in config set ‘Y’. That can occur if you are using an Beans Config Set to group configuration files in order to simulate the runtime behavior of imports. The error is due to the fact that one configuration file imports another file that is also part of the same config set and is now being added to the set multiple times: using an import and directly using the preference page.
To get rid of that you need to either ‘Enable Bean Override’ in the Config Set preference page or remove the configuration files from the config set. There might not even be the need for a config set any more.
Detection of Tooling Annotations in Namespace Schemas
Since the Introduction of the XSD-based configuration style in 2.0 of Spring a tooling specific namespace has been available. The <tool:* /> namespace defines meta data that can be used to annotate your own custom namespaces elements. These annotations are good to describe that a configuration element exposes a bean of a certain type or that an attribute takes class or interface names or bean references.
Spring IDE 2.0.3. will look for those annotations and automatically provide content assist and hyperlinking in the XML editor and create beans in the Spring structure model displayed in the Spring Explorer and used during validation. There is no need to implement a custom Eclipse plug-in to get support for an extension namespace.
You can see an example of tool annotation usage in the oxm namespace of Spring Web Services.

In order to read the annotations Spring IDE looks up XSD schema files from the Eclipse XML Catalog. Therefore it is important that the XSD is known in the catalog and recognized by the XML editor. You can easily test if the schema is correctly installed by using code completion on the custom namespace elements or attributes.

Published by Christian 1 year, 3 months ago
In case you have missed it: recent post-M4 nightly builds of Spring IDE contain basic support for Spring JavaConfig.
Just add the ConfigurationPostProcessor and a bean that is annotated with @Configuration to your bean definition XML file. Spring IDE will parse the configuration class and create bean definitions for every bean creation method - method annotated with @Bean - found in the class hierachy.
At the moment the support does not create bean dependencies by parsing the code of the bean creation method like it was implemented in an earlier prototype - is this feature actually desirable. Furthermore the @SpringAdvisor and @SpringAdvice annotations are not recognized by Spring IDE. Both features will be added later.
Note the little @ overlay image on the beans in the Spring Explorer and Beans Cross References View in the following screenshot. This overlay indicates a bean created by the ConfigurationPostProcessor.

Published by Christian 1 year, 9 months ago
in Journal.
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.
Recent Activity
Erik Weibust, aaaa, Cruise Answers
Vinoth, Pavan, , x, x, Manish Kl, mr.tianshu, René, Xiangyang, Jeff Mutonho [...]
Ashley Wong, Alessandro, Reza Payami, Christian, Senthil, Chris B, Christian, Senthil, Christian, Zolinko [...]
Scott, Christian, Randy, xe, Gabriel, coredump, Christian, Mike Hiner, David Newcomb, Nicolas [...]
Christian, djo.mos
Krish, sebdet, Christian, Eugene Lucash, Christian, Eugene Lucash, Christian, Angel