Singlesourcing RAP: An aspect-orientated approach
8. July 2009
Yesterday I was in Ettlingen at the Eclipse Application Developer Day and listened to Benjamin Muskallas track on Singlesourcing the RCP Mail Example. He explained that it needs 2 modifications of the generated RCP application to get the example running with RAP. The first was modifying some declarative data of the bundle, which is understandable; the second change required a direct edit within the RCP Code because the ActionFactory.ABOUT workbench action is (yet) not supported by RAP. The fact of editing RCP code directly is IMHO a critical point in enabling (probably already delivered) RCP applications. I want to show a way how to avoid such modifications with an aspect orientated approach, I’ve learnt on the EclipseDemo Camp in Leipzig, 3 weeks ago, from the team of ObjectTeam. They provide an extension which is compiled with a modified Eclipse Java Compiler and enables some features for modifying call hierarchies; see the website for details.

Compile-Error with RAP Target
So I installed the ObjectTeam Development toolkit and created a bundle which has only one purpose: Overriding the #makeActions method in the ApplicationActionBarAdvisor for instantiating an About-Action which is compatible to RAP. Therefore you have to “reimplement” the whole method-body, which can be difficult, especially on complex methods which probably referencing classes that are not visible.

Code for replacing a method
Afterwards created a launch config, set the OT/Equinox flag and voila:

RAP Mail-Example with untouched ApplicationActionBarAdvisor
This approach is probably a bit complicated but has a big advantage: You don’t touch your RCP code. Happy Singlesourcing
Download
Download the Example as Eclipse-Project - OT Development Environment required (130 Kbyte)



Hi Tom,
As I said in the talk, the suggested way is only one possible approach how to do single sourcing with RAP. But it’s really nice to see other approaches bubbling up. And I think the argument about already delivered/built applications may be interesting for some use-cases. But no matter which way you choose to single source your application, you still need to be careful about the semantics.
Nevertheless many thanks for sharing your experiences!
Comment by Benjamin Muskalla — 9. July 2009 @ 00:25
This is awesome! It love it when ones can make magic with equinox. I try to write an aspect for my RCP application with OTDT and it works! I’v also played around equinox aspect and I must say, OTDT has a very nice approach. Thanks for this tutorial, and thank you for sharing your experience. Great work!
Comment by Dimitri Koami Missoh — 11. August 2009 @ 17:23