Saturday, April 18, 2009

OSGi on AppEngine?

As many people know, Google recently announced support for Java on its AppEngine platform. As a connoisseur of OSGi, the first natural thing that came across my mind was quickly I could get OSGi running on it. Well, I’m happy to announce that we are part way there. I have OSGi running locally on the AppEngine SDK using the Equinox servlet bridge. I’ve managed to get a basic environment running with Equinox (and some bits of p2) and the Knoplerfish console: This wasn’t easy and was full of problems. If you read the AppEngine documentation, the sandbox is quite restrictive. First, there were a few places we were setting the context classloader and AppEngine doesn’t like that. I managed to hack the Equinox servlet bridge and the Equinox http service to not do that (it’s only needed in certain cases). Second, there’s a JRE “whitelist” of classes you can access that can cause trouble. I think this isn’t much of a problem if we define a custom OSGi execution environment for AppEngine. I attempted to do this since in Eclipse 3.5, we support the definition of custom execution environments. However, I found that the current whitelist doesn’t seem to be complete (maybe someone from Google can help). If you solve those problems, you can get Equinox working locally within the AppEngine SDK (as seen in the screenshot above). Here’s a zipped project if you’re interested (see the Equinox OSGi shared launch configuration and just go to localhost:8080/console). In reality, this is only half of the battle. If we actually try to deploy what we have created above, things will fail. The most complicated problem I came across with running OSGi on AppEngine was you can’t write anywhere to the file system. Equinox and other OSGi frameworks need a place to write its state. I think we can get around this if we write a custom storage adaptor hook in Equinox that uses the AppEngine storage facilities, however, that’s going to take some effort. That’s it for now. I plan on making some more progress next week… are there any other people that want to see OSGi running on AppEngine? Have any other people out there been experimenting with OSGi and AppEngine? Did you hit the same roadblocks? Do you want to collaborate?

No comments:

Post a Comment