Tag Archive for 'aspectj'

Insights of Spring IDE’s AOP support

In a previous post I gave our users some first details about what Spring IDE’s AOP support is going to offer.

Without further requirements Spring IDE will provide the following:

  • Parsing of AspectJ Pointcut Expressions in Spring configurations. Giving you error markers if the pointcut expression is syntactically incorrect. The same is true to @AspectJ-style pointcut expressions.
  • Visual markers for advised beans and advising beans and their corresponding Java classes and methods. That works for Spring AOP configuration using the <aop:config /> and <aop:advisor /> elements and for @AspectJ-style aspects and <aop:aspectj-autoproxy>.
  • To actual see what bean advises what other bean, we provide our own Beans Cross References View. This view visualizes your Spring AOP configuration and will allow the navigation between participating Spring Beans and Java classes. Furthermore the view will refresh automatically if you select another element either in the Java Editor or the Beans XML Editor and present the Beans Cross References for the selected scope.

If you have the AspectJ Development Tools installed you can get even more:

  • Reference contributions to AJDT’s Cross Reference View. Make sure that you enable Spring IDE’s provider in the view’s preferences.
  • Custom provider for AJDT’s Visualiser to see how and where your aspect and adivsors apply across your entire project.

A note about classpath settings

To allow Spring IDE to successful do the parsing of the AOP configuration, it is crucial that the project’s class path contains all required dependencies. The Spring IDE AOP parser will take your project’s classpath to load all classes from; Spring IDE will not instantiate the classes as we only need the Class. So make sure that the class path settings will allow loading an ApplicationContext from the configuration file. E.g. just execute a small JUnit to verify this; successful compilation isn’t enough as we need to load the classes including all their dependencies.

Showcasing the features

Most of you might know the JPetStore sample application and especially the implementation shipped with the Spring Framework. I’ll take this project to demonstrate the AOP support features.

First let’s start of having a look at the Spring configuration file that takes the definition of application’s business layer. Including transaction boundaries and attributes as well as some AOP demo stuff for sending emails.

If you open up the file in Eclipse you should see Spring IDE AOP markers. For the sake of consistency the icons were taken from the AJDT project. Furthermore the Beans Cross References View will display the cross references of the selected element in the xml editor. Refer to the following screen shot to get a gist how that looks.

Certainly you can use the Beans Cross References View to navigate to the Java class or method that either represents the adivce or that is actually advised. For example navigate to the PetStoreImpl.insertOrder method and you’ll see that this method is around-advised by the tx:advice and the emailAdvice. Furthermore you should find the cross references in AJDT’s cross reference view-if you have the AJDT plugins .

Last but not least you can bring up AJDT’s Visualiser and enable the Spring AOP Provider in the Visualiser’s preferences. This view can give you real quick overview of what advice is executed where in your project. Sticking with the example, only the PetStoreImpl class is advised as you can see in following screen shot.

New features in Spring IDE 2.0 M1

Today - after one year of development and the announcement at the TSE 2006 - Torsten and I are proud to present the first development milestone of Spring IDE 2.0, the upcoming major release of the Eclipse toolkit for Spring Development.

This release comes packed with some really cool new features incl. support for Spring 2.0 XSD-based bean definition files in the core model and the Beans XML Editor, a brand new Beans Explorer and - last but not least - support for Spring AOP based on AspectJ Expression Pointcuts and @AspectJ-style aspects.

You can install the Spring IDE 2.0 M1 release from our developer update site that is available at http://springide.org/updatesite_dev.

XSD and namespace support

Spring IDE’s internal model now leverages the tooling API introduced with Spring 2.0 (thanks Juergen and Rob for your ongoing support and patience). Therefore we are able to get the required information from the NamespaceHandler implementations that are necessary to build the graphical tree for the Beans Explorer or the Beans Graph.

Beans Explorer

The Beans Explorer replaces Spring IDE’s Beans View, but presents basically the same information: a grahical tree of your Spring bean definition files and their combination on Beans Config Sets. We decided to re-implement this view using the Common Navigator Framework from Eclipse 3.2. So after installation of Spring IDE 2.0 will not see the Beans View anymore; instead make sure that you open the Beans Explorer (via Window -> Show View -> Other... -> Spring -> Beans Explorer or via Navigate -> Show In -> Beans Explorer).

Content Contribution to Eclipse’s Project Explorer

Eclipse 3.2 ships with the Project Explorer (openable via Window -> Show View -> Other... -> General -> Project Explorer or via Navigate -> Show In > Project Explorer) which is based on the Common Navigator Framework as well. Spring IDE contributes additional content to this view (enabled via Filters... -> Available Content):

Contributions to Project Explorer and new Beans Explorer view

As you can see in this screenshoot the Project Explorer shows for every Bean class the references from the corresponding Beans Config files. This (in combination with Eclipse’s navigate back / forward actions) can be very handy for navigating between Spring bean classes and Beans Config files.

XSD and namespace support in Beans XML Editor

Spring IDE now supports a broad range of content assists and hyperlink navigation for Spring 2.0 namespaces, like <aop:*> or <util:*>. Make sure that you check out the content assist proposals and provide us with some feedback on missing assists or any inconsistencies you may observe.

Certainly the famous p namespace is supported as well. For more see SpringsPNamespace.

Furthermore we provide extension points for custom namespace developers to contribute their own content assists to the editor. I will blog about the extension point in another blog post later on.

AOP support

After I first heard about the AspectJ integration with Spring, I wanted to bring the capabilities of the AspectJ Developer Tools and Spring IDE together in order to provide an integrated development experience for AOP that supports both worlds. At first that didn’t seemed to be quite possible, both technically and time-wise. Therefore I postponed this feature to a later time…. Beginning of December I wrote a mail to Adrian and Matt, cc’ed Rod to start a brainstorming process with the guys from AJDT.

I got back a mail from Rod Johnson, that quite challenged me to get that working:

Christian

This would be a *fantastic* feature! I hope it is technically feasible…

Rgds
Rod

(Rod, I hope you are ok with this public quote?!)

So here is what Spring IDE 2.0 M1 will offer you:

  • Parsing of AspectJ Pointcut Expressions in Spring configurations. Giving you error markers if the pointcut expression is syntactically incorrect. The same is true to @AspectJ-style pointcut expressions.
  • Visual markers for advised beans and advising beans and their corresponding Java classes and methods. That works for Spring AOP configuration using the <aop:config> elements and for @AspectJ-style aspects and <aop:aspectj-autoproxy>.
  • If you have AJDT installed you will get the same Cross Reference information you know from AJDT. So open the Cross Reference View and watch your bean’s Java Elements cross referencing ;-)
  • To actual see what bean advises what other bean, we provide our own Beans Cross References View. This view visualizes your Spring AOP configuration and will allow the navigation between participating Spring Beans and Java classes. Furthermore the view will refresh automatically if you select another element either in the Java Editor or the Beans XML Editor and present the Beans Cross References for the selected scope.

You will find the Beans Cross References View under Windows -> Show View -> Other -> Spring. Make sure that you define the Spring configuration file as Spring IDE Beans Config and do a project build. After the build you should get the markers and some content in the cross reference view.

Site note: Spring IDE support does not rely on AJDT at all. So there is no need to install AJDT (although you really should). We are using Spring’s AOP support classes to do all the pointcut parsing and matching magic. Unfortunately we are currently not able to determine advised beans that are created by NamespaceHandlers or Factory beans. Furthermore we are not supporting Introductions and the <tx:advice>, yet.

More to come

That’s it for today and most likely for the year of 2006. But there is some more stuff in the pipeline for the final Spring IDE 2.0, like the Web Flow Editor, Java configuration and adding validation support for the namespace elements. Watch out for more ….

Please, make sure that you find time to install M1 and play around with the Beans XML Editor, the Beans Explorer, the Project Explorer and the AOP support. It would be really helpful for us to get some feedback from real projects out there using our plugins. So head your Eclipse Update Manager to http://springide.org/updatesite_dev and download the release.