Integrating a legacy Swing application in an Eclipse RCP application

The following points have to be considered: <ul> <li> Bidirectional synchronous and asynchronous communication has to be possible. </li> <li> It is not allowed to just copy the whole legacy Swing application into the Eclipse RCP application. </li> <li> The legacy code is still in use and so the changes on the Swing side has to be minimal </li> </ul>
1 answer

Use a custom classloader and interfaces for such a task

This was a very tough issue - it was not allowed to copy the whole Swing application code into the Eclipse RCP because the maintenance effort would be doubled because of the doubled code base. So this was no option. Another problem would be the size of the deliverable - instead of shipping an Eclipse RCP application with 150 MB we would have to ship about 500 MB and we would have to roll out the 350 MB if there is one little bug in the Swing part.
The Swing application has to be standalone and can be started inside the Eclipse RCP application and outside of it but not at the same time. So we have to load the Swing application on demand at runtime. To achieve this we implemented a small library containing 2 interfaces - one interface was implemented on the Eclipse RCP side and the other one on the Swing application side. Now we just have to create a custom classloader which loads all the classes necessary for the Swing application and create an instance of the class which implements the interface.
This is just a way to integrate a legacy Swing application into an Eclipse RCP application - there are many more problem regarding SWT-AWT threading, different bugs in the SWT-AWT bridge etc.