Saturday, November 6, 2010

Uhh we have color: Running a legacy app on eclipse e4

I came back from ESE with lots of inspiration. So I couldn't stop and had to try our RCP application on e4 for the first time.

I had a little fight in getting everything up, the e4 sources are missing in the M3 download (theres a bug for that) and you have to install the tooling seperately. So I just pointed e4 to my workspace, switched the target platform and tried to launch. Oh, yes now we need an application model.

Setting up the application model for a legacy app seems to be not well documented, I didn't know at all what elements I would need as I was starting from zero. So I had a look at the example e4 app and stripped down the e4xmi to my needs.

<?xml version="1.0" encoding="ASCII"?>
<application:Application xmi:version="2.0" xmlns:xmi="" xmlns:xsi="" xmlns:advanced="" xmlns:application="" xmlns:basic="" xmlns:menu="" xmi:id="_lYit4OjtEd-nIcCsQMihjw" elementId="">
  <children xsi:type="basic:TrimmedWindow" xmi:id="_lWJrwOjuEd-nIcCsQMihjw" elementId="" label="Buchmanager" iconURI="platform:/plugin/" width="1024" height="768">
    <children xsi:type="advanced:PerspectiveStack" xmi:id="_bXMvVejuEd-nIcCsQMihjw"/>
    <mainMenu xmi:id="_xpyAkOjuEd-nIcCsQMihjw" elementId=""/>
    <trimBars xmi:id="_CnxywOjvEd-nIcCsQMihjw">
      <children xsi:type="menu:ToolBar" xmi:id="_DF-xsOjvEd-nIcCsQMihjw" elementId="toolbar:org.eclipse.ui.main.toolbar"/>
  <addons elementId="MinMax Addon" contributionURI="platform:/plugin/org.eclipse.e4.ui.workbench.addons.swt/org.eclipse.e4.ui.workbench.addons.minmax.MinMaxAddon"/>
  <addons elementId="DnD Addon" contributionURI="platform:/plugin/org.eclipse.e4.ui.workbench.addons.swt/org.eclipse.e4.ui.workbench.addons.dndaddon.DnDAddon"/>
  <addons elementId="Cleanup Addon" contributionURI="platform:/plugin/org.eclipse.e4.ui.workbench.addons.swt/org.eclipse.e4.ui.workbench.addons.cleanupaddon.CleanupAddon"/>

--27.02.2011 this xmi is a little buggy. Try the LegacyIDe.e4xmi from the platform plugin instead.

You basically need a menu and toolbar hook, and a perspective stack. the addons are needed to get the usual behaviour on views and editors for resizing.

Some things didn't work from scratch with my perpectives, but I received patches in almost no time when I reported the bugs to the e4 team. Still one issue open, but I think that will get fixed soon, too.

Finally I stole some eclipse css file and added the theme extension point to my app.
So now my app looks a little more "sexy" in terms of colors and styling. I could get used to it.

Did I mention that I didn't change a single line of the 3.6 based code ? The compatibility is great.

Monday, November 1, 2010

Porting to virgo - seeing some light

Some weeks ago I started some experimental stuff and tried to port our server to Eclipse Virgo. The code was based on spring configuration mainly, so I thought that I should be able to handle this.

Today I can connect with the client and most services are working fine. But if it has one drawback, it is that I had to build most of the library bundles on my own. And we use a hell of a lot of libraries. Hibernate is still not really OSGi-friendly as are other frameworks. Today a had a fight with JasperReports, which used to cause some headache even without OSGi, but with some drawbacks I finally can run our reports on virgo now.

I still must have an evil jar that wants org.apache.xerces as default instead of I thought I had removed all the xerces jars that come with frameworks here and there, and I cannot see what I have overseen today. I made my way round by setting system properties to the jre implementation which luckily made it work. (I needed at least a simple succes today)

Setting up the bundles correctly caused me some headaches over the last weeks. I had the hell of ExtendedClassNotFoundException, learned a lot about who is using whom in my jars. Some things appaered a little surprising to me as I had to import javax.sql for example in many bundles. I would have guessed that those jre packages are visible by default. But maybe someone explains the reason for this to me one day.

One thing that still annoys me is that virgo tooling for eclipse doesn't support PDE bundles. So I have the PDE and the Spring bundle project nature on some of my shared bundles (i.e. bundles that client and server need both for communication) which is really painful and error prone. Kai Toedter opened an enhancement request on this today.

But all in all its working, still have to do some refactorings on formerly static code that used to be called from main, but its not to far to go. Did not find a true showstopper up to now. When all is done I need to work out a proper Installer that will migrate an exisiting configuration into virgo, but that seems to be not to complicated as virgo con pick up existing property files when I put them in the repo.

Now for today I have two different versions of lucene running in parallel, next step I could throw in a current poi instead of that one jasper report uses.

But most of all I'm looking forward to the ease of deployment on my customers sites in the near future. The day they all will have virgo installed, upgrading the whole thing will simply mean uploading a new release to central virgo and p2 repositories. I still have to think my way to the strategy (what about errors on schema upgrades ? I see them at least at one customer at each new release, customer have data you can't think of in advance) but all in all I'm very happy about that.

I'll be talking about the update scenario in detail at ESE on Wednesday afternoon, so come and talk to me if this is something you are into !

Jupyter Kernel for Java9