Wednesday, November 19, 2008

Building a Dev Box

Although I am the sole developer on most of the software projects I currently work on, I often haven in the back of my mind the steps that another developer would have to go through to contribute to a project. I think this is usually a good consideration as this line of thought forces me to at least try to establish a simple development and test environment, and to try to write clear and easy to work with code. Before a fellow developer even looks at a line of code for the littleware project he or she has to install a series of software packages on his machine to build up a base development environment. Here is a quick rundown of several of the packages I install on a box that I expect to develop on. This list is not comprehensive, but it has the big pieces.

Saturday, November 15, 2008

Guice and OSGi

I've been working on and off for the past couple years on a client-server data tracking framework I call "littleware", and over the last month I began revamping the dependency injection bootstrap code on the server side. I've already converted the client side to use Guice, and that has worked out great. A Guice trick that has worked very well for me on the client is to setup a Properties file that defines static user preferences .ini style, then have a Guice module pull Guice @Named constant values for injection.

On the server side I plan to try a two phase bootstrap process using both Guice and OSGi. The second OSGi phase will allow each bundle that contributes to the application to run through the OSGi startup/shutdown life cycle. Leveraging OSGi will also allow each module's code to take advantage of OSGi's service publish and discovery infrastructure. Here is what I have in mind.

  • First an application bootstrap method run by a configuration servlet will load a bootstrap.properties file to pull a list of Guice module classes and a list of OSGi BundleActivator classes.
  • Next the bootstrap method will allocate each Guice module via java reflection invocation of each module's no-argument constructor, and give the list of modules to Guice to create an injector.
  • Third the bootstrap method will use the Guice injector to allocate each OSGi bundle activator.
  • Finally, the bootstrap method will startup an embedded OSGi environment (probably Apache Felix), and seed the OSGi environment with the list of bundle activators.

This will be my first experience using OSGi, but I've read good things about it, and I know several prominent projects take advantage of it. I know OSGi has some support for dependency injection, but I've had greate experience with Guice, and Guice seems much better suited to that task. If all goes well, then I may extend the client to leverage OSGi in the same way. I'd like to extend the current client framework to embed several server-side technologies like javadb so that multiple clients running on the same machine can share services - especially cacheing.

Hopefully I'll be back in a month or so with a status update. I played around with maintaining a blog of XML files on my own server, but services like blogger are obviously a much simpler and better solution that I plan to take advantage of for now.