Plugable Swing – A Hello World OSGi Example
Join the DZone community and get the full member experience.
Join For Freethere are a lot of osgi applications available, but a minority of them is aimed at the client side. here i will list some on swing:
- http://felix.apache.org/site/apache-felix-application-demonstration.html
- http://danielrohe.wordpress.com/2009/04/01/swing-application-on-osgi/
- http://www.toedter.com/blog/?p=33
- http://code.google.com/p/osgi-in-action/
- sip-communicator
today i tried the same and had luck. it was very fast (~1h) to get all working what i wanted, because i shamelessly stole the code from the example of apache felix. it is even more easier than this example but should have the same effect: it shows how one could use osgi even for a swing application.
there is a host application called swing on osgi – host with one jmenu which does not change (static) and one (dynamic) jmenu which could be changed from the available plugins (here only one: swing on osgi – plugintest ). the source code (apache license 2) can be checkout via
svn checkout https://timefinder.svn.sourceforge.net/svnroot/timefinder/branches/swingosgi swingosgi
… you will need maven. after ‘mvn install’ for both projects you will only need to start the host application via your ide or via
java -jar target/host-1.0.0.jar
then if you see the “dynamic menu” with one menu entry (which was added from the plugin) all is fine:
if you have problems while building this send me an email or comment here.
i got the plugins even working in my timetabling application timefinder which uses the client-side framework called spring rich client . the first plugin for spring rich client - read more .
Opinions expressed by DZone contributors are their own.
Comments