[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.technology.equinox] Re: Integrating Swing apps on top of Equinox

I'll spare you a lecture on 'Krusty, the Swing App', but there is some evidence that your attempt is indeed akin to a trapeze act in an entertainment setting (Honk! Honk!).

None of your issues are in any way OSGi-, or Equinox- for that matter, related.

Granted, since Swing libraries are now by default a part of the Java platform, Java's 'Parent Delegation' class-loading model will resolve the Swing classes at the level of the Bootstrap class loader. Any static assignment is scoped at that level in the class loader hierarchy and is therefore out of your control. That's the idea of 'trusted classes' in security model 1.2 for ya ;)

Your solution is the only possible solution to your conundrum (even more elaborate constructions excepted).

You might feel that this is a hack, but I have reason to suspect that the uncomfortable feeling you are experiencing is probably your local usability engineer who has clawed her- or himself around your throat out of desperation. Congratulations! You have managed to build the mythological two-headed monster. A single application with two (2!) simultaneous Look and Feels for the price of one. With an added surprise effect of indeterminate behavior.

Is this a project for Cirque du Soleil?

Or is your product manager simply a slow starter? Is her or his mind wandering because of an impending foreclosure? Have you been refused escalation because she or he advocate non-violent protest?

As far as I can tell, this is not an engineering problem. It's one of those cases which demonstrate how some IT projects can go 'weird' without anyone raising a finger or going: 'Hold on a minute!'

This picture might be helpful to print in poster format at your office:
http://images.google.be/imgres?imgurl=http://thevoiceforschoolchoice.files.wordpress.com/2009/07/square-peg-round-hole.jpg&imgrefurl=http://thevoiceforschoolchoice.wordpress.com/2009/07/14/traditional-public-schools-not-ideal-for-every-child/&usg=__AhH3vppZRw8LQMIevX9rWdJIGqM=&h=414&w=290&sz=90&hl=nl&start=1&um=1&tbnid=OFS1I0TWuvRyVM:&tbnh=125&tbnw=88&prev=/images%3Fq%3DSquare%2BPeg%2Bin%2Bthe%2Bround%2Bhole%26hl%3Dnl%26client%3Dfirefox-a%26rls%3Dorg.mozilla:en-US:official%26sa%3DN%26um%3D1

You're welcome,
 Dann



Eva Troels wrote:
Hi everyone,

We have two old, crusty Swing apps that we want to integrate on top of Equinox.
There are several reasons for this decision the most important ones being:
- No clashing third party libraries (the two apps run different versions of xerces, velocity, and several other open source products)
- Dynamic updates (the apps can be updated independently of each other)


I am fairly new to OSGi and Equinox and have experienced my share of ClassNotFound and Class Cast Exceptions over the last few weeks.

Now, the two apps run and all is good. Almost. We had to do a few workarounds. The one bothering me the most is the fact that we had to change the applications' Look and Feel:

The applications both have Swing GUIs. This is easy: Just let the two bundles import javax.swing and start popping up the JFrames.

But...The two apps have different look and feels. And these are setup with calls to static methods in Swing. So the result depends on the launch order. If app A wins the look and feel tug of war, the two applications run albeit application B looks a bit different than usual. If app B gets its way app A craches.

How to avoid this and let the two applications have each their look and feel - isolation with regards to Swing packages.

My one solution is: Extract Swing classes for Java's rt.jar and create two new bundles:
- SwingBundleWithAppALookAndFeel
- SwingBundleWithAppBLookAndFeel
and then setup the bundle interdependencies accordingly.


This, however, feels like a major hack and I'm not even sure, that it works.

Please feel free to share any comments!