Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Integrating Swing apps on top of Equinox
Integrating Swing apps on top of Equinox [message #483068] Sun, 30 August 2009 19:03 Go to next message
Eclipse UserFriend
Originally posted by: eva.troels.org

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!
Re: Integrating Swing apps on top of Equinox [message #483070 is a reply to message #483068] Sun, 30 August 2009 20:17 Go to previous messageGo to next message
Dann Martens is currently offline Dann MartensFriend
Messages: 65
Registered: July 2009
Member
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://thevoiceforscho olchoice.files.wordpress.com/2009/07/square-peg-round-hole.j pg&imgrefurl=http://thevoiceforschoolchoice.wordpress.co m/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=OFS 1I0TWuvRyVM:&tbnh=125&tbnw=88&prev=/images%3Fq%3 DSquare%2BPeg%2Bin%2Bthe%2Bround%2Bhole%26hl%3Dnl%26client%3 Dfirefox-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!
>
Re: Integrating Swing apps on top of Equinox [message #483090 is a reply to message #483070] Mon, 31 August 2009 05:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eva.troels.org

Thank you for you honest reply! I have printed out the
square-peg-round-hole image and will be sure to staple it to my letter of
resignation :-)

I think that we will continue with just one look and feel for both
application and in a most democratic way, the most picky application will
have its way.

In earlier version of java, Swing DID have its own swingall.jar.
It seems to me that it would be a good decision to go back to this. rt.jar
would be smaller (something that some people seem to care about) and it
would give implementers a choice with regards to GUI platform.

Oh well...

Eva
Re: Integrating Swing apps on top of Equinox [message #483163 is a reply to message #483090] Mon, 31 August 2009 12:31 Go to previous messageGo to next message
Dann Martens is currently offline Dann MartensFriend
Messages: 65
Registered: July 2009
Member
Hi Eva,

Well, of course, I know that managers never listen to any engineering
advice and you might be forced to do the unthinkable anyway.

I agree that modifying the app which introduces the least effort in
terms of adopting a new Look and Feel would be a more sane thing to do!

Otherwise, even by manipulating the class loader hierarchy using two
separate instances of an older version of swingall.jar, the trusted
classes which come bundled with any post-1.2 JRE would be loaded first.

You'd have to break the parent delegation behavior in the same way web
applications (.war) do.

Actually, except for this system property:

-- SNIP --
osgi.compatibility.bootdelegation
if set to "true" then the parent (boot by default) classloader is
delegated to as a last resort if a class or resource cannot be found.
The default value is "true".
-- SNIP --

I haven't looked into the features of Equinox to do this at the level of
an individual bundle.

Best regards,
Dann


Eva Troels wrote:
> Thank you for you honest reply! I have printed out the
> square-peg-round-hole image and will be sure to staple it to my letter
> of resignation :-)
>
> I think that we will continue with just one look and feel for both
> application and in a most democratic way, the most picky application
> will have its way.
>
> In earlier version of java, Swing DID have its own swingall.jar.
> It seems to me that it would be a good decision to go back to this.
> rt.jar would be smaller (something that some people seem to care about)
> and it would give implementers a choice with regards to GUI platform.
>
> Oh well...
>
> Eva
>
Re: Integrating Swing apps on top of Equinox [message #483843 is a reply to message #483068] Thu, 03 September 2009 10:51 Go to previous message
Martin Lippert is currently offline Martin LippertFriend
Messages: 124
Registered: July 2009
Senior Member
Hi Eva!

In addition to the described solution there might be another one (also
not related to OSGi, Equinox, etc. at all). If you have control over the
two apps, you might think about using a special look and feel that
allows you to control the look&feel on a per-window base. Then you can
easily run l&f A for one app and l&f B for the other one while both are
running on top of standard swing:

https://substance.dev.java.net/

Maybe this helps...

Cheers,
-Martin



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!
>
Previous Topic:[P2] Remove plugins that are not included in an update of a feature
Next Topic:Equinox OSGi Server
Goto Forum:
  


Current Time: Fri Apr 26 11:27:16 GMT 2024

Powered by FUDForum. Page generated in 0.03187 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top