Assuming that it’s even possible, what would be your recomendations to make a bundle compatible between different platform releases? Specially between R3 and R4.
Update about my requirements:
The idea was to develop a web interface for a embedded device that currently runs an OSGi R3 container but that it could be upgraded soon to R4 (we don’t have much control over this). The web interface will be deployed using a OSGi HTTP service. I see three options:
- Do the application with R4 as I’ve seen that some web toolkits doesn’t work with older releases. I suppose that the providers of the device could deploy the current R3 bundles on R4 without much effort (but not sure).
- Implement the web interface with R3 and without the benefits of modern web toolkits (or recommend me one).
- Do it with some R4 bundles but some-way release-independent so we can finally deploy it on R3 or R4.
In general, R4 mostly introduced new headers for the bundle manifest, which R3 implementations ignore. There are a few semantic differences in import/export behavior but depending on what kind of bundle you’re making, those might not matter. One strategy you could use is to simply create an R3 bundle, which should still work fine on an R4 framework. You’d miss out on some new R4 features in that case, of course.
Follow up:
From the point of view of the HttpService, there are no big changes going from R3 to R4.2. The former uses the 1.1 specification of HttpService, the latter 1.2. The differences are minor (the spec uses the @since tags in the API documentation to explain what methods were introduced when).
It is completely true that R3 bundles work as is on R4. Keep in mind though that in practice you could discover bugs when running R3 bundles in R4. When R4 was just released, I moved a big project from R3 to R4 and we encountered lots of small issues, all our own fault, which caused bundles to fail on R4 while they were happily running on R3. These were mostly related to R4 implementations in general being more strict when it comes to delegating to their parent classloader. Make sure you test your bundles on the frameworks you want to deploy them on.
I am wondering, in what way do the web toolkits you looked at not work on R3? Do they depend on HttpService 1.2? I guess it would not be hard to run 1.2 on R3 yourself, or bridge it to an 1.1 implementation.