Java web app, with plugin framework and ability to connect to source for updates

javapluginsweb servicesweb-applications

I've searched all around for some good sources, but either have been searching for the wrong keywords, or I'm just missing something. I'm looking to redevelop a web app I've been using for some time now. Many parts are out of date, and we're constantly throwing in little hacks to attempt to give it new life.

So what I'd like to do is re-engineer it from the ground up, built on some sort of plug-in framework. Before I continue, I'm more or less an intermediate Java programmer. In some ways, I'm hoping to use this project as a big learning experience.

I've read a lot about OSGi, and it seems that's the most complete framework. Ideally, I would like an end result web app which I can run one instance as my hosting environment, and other instances can connect to it to grab new and updated plug-ins. Eventually I'll want to lock down these plug-ins based on some undecided criteria of who can get them (basically some will simply be updates, others will provide new functionality and should be "purchased" through an external system). But that will probably be handled in a later phase. There should be an administration view for managing bundles in a hot environment (looking to avoid having to restart the server for an update).

I know all these things are possible, I'm just trying to find some good resources for reference. All the OSGi tutorials I'm finding seem to be too simplistic. If anyone here can guide me in the right direction on any or all of the items I'm looking for, it would be much appreciated. Also, this is my first post, so I'll take any comments/criticisms about the content of my post. Thanks!

Best Answer

In OSGi there are a variety of available solutions for provisioning OSGi modules/plugins.

One of the approaches is the OSGi Bundle Repository (OBR). This is a system that can contain OSGi modules and serve as a provisioning system for your applications. It can be accessed from shell or an OBR Service API to resolve resources. It seems as a good foundation for a pluggable framework. You would need to have a central OBR which contains your plugins and an update module that uses the API to connect to it and resolve.

OBR is used in e.g. Bndtools for provision resources to Eclipse OSGi projects. Applications such as Artifactory and Nexus also provide support for OBR. More on OBR, OBR explained in OSGi In Action book.

As mentioned in the beginning there are other provisioning systems. Most runtimes (Eclipse Virgo, Apache Karaf) offer some sort of repository system (not always OBR) to provision bundles. They already have web applications available to view and interract with them. More on this in the answer given on this SO question. From OSGi R5 there are standardisation services for interacting with a lot of them. See these slides at eclipsecon.org about Subsystem Service, Repository Service and Resolver Service.

Finally I'd like to mention the Apache Sling project. It is a framework to build OSGi web applications but the interesting thing is that it uses the Java Content Repository specification to manage content. You can deploy Sling to any servlet container and it has a admin web application where you can manage OSGi bundles. It is fast to get up and running and try it out. You just have to deploy the Sling launchpad war. See more about Sling launchpad at sling.apache.org. I do not have much experience with developing with Sling, I have just used it to deploy OSGi web applications.

Basically, when using OSGi a plugin system is at your fingertips without implementing all of it yourself. Although it is hard to find real world examples I recommend using an existing provisioning system from an OSGi runtime or Sling to get your started quickly. A good resource are the Manning books on OSGi (OSGi In Action, In Depth & Enterprise) they helped me a lot in grasping the concepts and the examples are really good.