Pluggable Spring RC? (OSGi with Spring Rich Client)
Join the DZone community and get the full member experience.
Join For Freemy last post was about pure swing, which could be easily osgified. osgi technology can be used to hotdeploy or undeploy jar files to your application server (at the moment only spring’s server is suggested) or simply to update your swing application at runtime or write plugins for them. i don’t know for sure, but it seems to me that eclipse is the most prominent user of osgi (equinox is one implementation of the specification…) as desktop application, although netbeans can now use osgi bundles .
(btw: do you know a funny myth where the small “i” from osgi could come from? no? read the comments here !)
in the last post i show you several swing applications, which were successfully osgified, today i would like to list swing- or eclipse-based applications which use spring dynamic modules :
- https://spar.dev.java.net/
- http://sourceforge.net/projects/agilercp/
- http://max-server.myftp.org/trac/mp3m/ eclipse rcp
- http://max-server.myftp.org/trac/pm swing app framework, even webstart will work here
then today, in contrast to my last post, i would like to show you an identical solution for the spring rich client project .
why should i use another framework on the top of osgi? this is
simple: spring dm provides several nice features, like no dependency on
the osgi implementation (
felix
,
equinox
,
knopflerfish
)
and even no one on osgi at all. everything (and think) is a bean, like
always! but why spring dm? why not declarative services from osgi
itself or
apache ipojo
? this is simple: i don’t know the others and spring rich client cries for the spring solution
but to make this short story very short: after struggling the last two days to get spring dynamic modules integrated with spring rich client i gave it up and tried the pure osgi solution – and – it works. it might be an ugly solution for all those of you who like dependency injection, but this can be optimized later. today this might be the first plugin for spring rich client – ever:
the button “say hello” with its joptionpane message was installed through the dynamically loaded plugin. the source code is nearly identical to the one in my previous post. just add the spring rc startup before you grab the menu from the application to create a menutracker, which calls the menuservice(=plugin):
@override
public void start(bundlecontext context) throws exception {
startup.start();
menutracker = new menutracker(context, application.instance().getactivewindow().getcontrol().getjmenubar().getmenu(1));
menutracker.open();
}
the source is available from my timefinder project via:
svn checkout -r 595 https://timefinder.svn.sourceforge.net/svnroot/timefinder/trunk timefinder
be sure to start the application from de.timefinder.core.osgi.activator (main method!).
i hope this post inspired someone to be the first one with spring dm + spring rc marriage … or sb. suggests working examples how spring dm could be started from command line or from netbeans.
Opinions expressed by DZone contributors are their own.
Comments