Plugable Swing – A Hello World OSGi Example
Join the DZone community and get the full member experience.Join For Free
there 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:
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.
Opinions expressed by DZone contributors are their own.