About OSGiNews and EventsMarkets and SolutionsSpecificationsWork GroupsUsers' ForumsLinksJoin
OSGi Bundle Repository2008-07-30
Add a comment
OSGi Application Grouping2008-07-17
Several people in and outside the OSGi want application grouping. They want to be able to deploy a set of bundles as an "application". These "applications" should have some scoping on class loading and service issues. I am opposed to this but, as Eric Newcomer pointed out to me last week in Dublin, I never really made my case and shown a solution to some of the valid requirements. So, here it is ...
Back to basics. In the beginning, OSGi was about providing functionality to a device. Adding bundles would add more functions and removing bundles would get rid of those functions. Key was that these bundles would collaborate, they would not just be started and running in some silo container; ignorant of their siblings around them. However, these bundles would not have a priori knowledge of each other because the business idea was that different service providers would supply them independently. The only way you can make this work is if you have a communication model that allows you to very loosely couple the bundles. This was the service model. The service model is very simple: the producer registers some object under an interface and the consumer gets it through the interface. The implementation is safely hidden, the consumer has no clue. Unfortunately, this service model required rules about class loading because those service interfaces involve classes and you better make sure that the producer and the consumer both share the same class loader for that interface/class. It was never the original intention to share implementation classes between bundles because bundles were supposed to communicate through services with a minimal interface to promote loose coupling. Sharing implementation classes was more or less an unintended side effect. Prior to R4 we could not even support multiple versions of the same exported package because that need is not very acute in a service oriented world program. In the meantime at plain Java, the poor man's extension model became Class.forName. Where the OSGi model offers the services to the consumer, in the poor man's model the consumer creates the services through dynamic class loading, albeit with the indirection of some XML or other text file. This, alas, requires implementation visibility into the provider bundle. The popularity of this Class.forName extension model makes the OSGi class loaders on steroids the most attractive aspect of OSGi for many people. However, having to export implementation classes from a bundle obviously opens huge holes in the modularity story, suddenly you are exporting implementation classes to the world. This makes the coupling a lot less loose. My personal feeling is that application models are only trying to patch up these modularity holes with an emergency bandage. This is like drinking heavily and then taking aspirine against the headache. Maybe less drinking would be healthier? This said, there is of course a concept of applicationness, otherwise not so many people would demand it. However, I do feel that the bundle is the right granularity for application granularity. A good bundle provides one or more functions and expresses dependencies on other bundles through services. That is all, no other primitives are needed (the services imply one or more Java packages). If I want to run an application I pick a bundle that provides me with the right functionality. Systems like OBR can then be used to find bundles that provide the needed services. Dynamic dependency resolving is needed to create flexible systems. One of the key problems with an application model is that it fixes the application to a specific set of bundles; making it applicable to only one environment and thereby limiting severely the overall reusability. One of the key issues is of course testing. Many companies want to be able to send a set of bundles to QA and be sure that that is exactly the set that will be deployed on the target system. I do understand this issue. However, I think that the best solution to this requirement is to run these bundles in a framework, or even a VM, of their own. In certain cases, it is even wise to just wrap up all the bundles into one so you are sure they can not be separated. From a modularity perspective, if these bundles are so closely coupled together, why separate them? Fortunately, the EGs have come up with a model that seems to fit the needs to scope a set of bundles: nested frameworks. They are currently investigating a solution where you can create new frameworks inside an existing framework with relatively little cost. This solution seems to be very unintrusive to the spec because it adds a feature but does not (I hope) influence the existing features, at least not in a major way. Nested framework allow a managing framework to create nested frameworks for each "application". Services can be shared between frameworks by using the existing notification mechanisms and registering the service in alternative frameworks. Even packages could be shared with the To conclude. I think the demand for an application model is largely driven by problems that are caused by the Class.forName extension model and tight coupling that caused developers to share implementation classes. Even after ten years I think that the bundle-service model of OSGi is the cleanest solutions to software development that I know. I do hope that we will not dilute this model by patching OSGi to support the lesser implementation class sharing model. Then again, with nested frameworks we all can seem to get what we want! Peter Kriens CommentsEd Merks :
Keep up the good work Peter. Resist the temptation of the dark path. It leads to ever more complex abstractions that will have new problems of their own that will in time lead to the next complication. It's better to add a new aspect to an existing concept than to invent a whole new concept.
Mike Francis :
Peter
A very interesting post highlighting an interesting challenge. It's something we have sought to address with Infiniflow and Newton without needing to change the OSGi standard. You can read my colleagues thoughts at http://chronological-thought.blogspot.com/2008/07/is-this-application-which-i-see-before.html. Madhav :
Hi Peter,
The requirement that i have seems to be a generic requirement and at present i do not know how the community in general handles it. We have a layered architecture, where a layer at the bottom provides bundles which are then available to the layer above. Now we have this structure at the design time but if we want to maintain at the run time then what would be the best approach? This would include things like: 1. Run levels defined on a layer rather than on individual bundles 2. Defining restrictions on the availability of services exposed by certain bundles to say 2 layers above, but they can be accessed within a layer and a layer just above it. These are just a few of the requirements. Do composite bundles solve the problems? I saw then 4.3 early draft spec for osgi-core but was not sure if they would solve the run level problem. Nested frameworks would not help in this case as per my knowledge. Best Regards, Madhav QVO VADIMVS?2008-07-02
We are seeing more and more outlines appearing for the next OSGi release. One of the major issues is legacy code. Not only inside the OSGi, but if you go to the web you see a lot of people struggling to get old code to work inside OSGi frameworks. Obviously, we want to mitigate the issues around legacy code as much as possible, the more people that use OSGi the better. However, lately I have some (personal, this absolutely is not an OSGi standpoint!) musings about how to attack the issue of legacy code.
A short story to illustrate my musings. In the eighties, I worked on a page-makeup terminal for the newspaper industry. Petr van Blokland, a graphic designer turned computer specialist, introduced me to the layout grid. This grid had columns and between the columns there was a small gutter. Text and pictures were placed on this grid, usually encompassing multiple columns and gutters. Like: ![]() The OSGi always reminds me of this grid. Why? Because they both restrict you severely but in return they provide simplicity. Instead of having infinite freedom to do whatever you feel like, you must obey some pretty basic rules, which some people find upsetting. But what you get back is that the elements work together as a whole, instead of fighting with each other. Layouts done with this grid almost invariably look good with no effort (try working with the average layout manager in Swing or SWT!). The advantage is that elements always line up and there is always the same space between elements. Without a grid, it is very hard to avoid unwanted visual effects. Genuine OSGi bundles almost invariably collaborate with each other without much effort (anybody saw the combination Eclipse and Spring coming?) because modules are self-contained and can only export packages and communicate via services instead of the myriad of ways people have devised in Java. Interestingly, both are achieved by restricting ones freedom, the opposite of providing more features. But neither OSGi nor this grid is simplistic. A simplistic grid would be a square 8x8 grid, and they just do not work. A simplistic OSGi would be some Class.forName based system without handling versions and dependencies. Both OSGi and the grid seem to be in a sweet spot: simple but not simplistic, providing maximum bang for the buck. However, legacy code seems to be forcing us to add more and more mechanisms to the OSGi specification. Unfortunately, these mechanisms are often also then used for new OSGi applications because the legacy concepts they represent feel familiar to people. See how many people use Require-Bundle and fragments. If we add all these freedoms to the next generation, will we not pollute the original model and become in the end much less attractive? Or, if we do not make it easier to use legacy code, will people turn away because they feel affronted that their direct needs are not addressed? Should we leave these issues to framework implementations making legacy code not really portable? The current popularity of OSGi seems to allow the OSGi to make a stand. What do you think? Peter Kriens Commentsrbrown :
There will never be a way to please everyone but maintaining simplicity and staying true to OSGi's original model (which works!) will have the most long term benefits. Remember, it is the original model that is behind OSGi's current momentum and success.
I was personally attracted to OSGi because of its simplicity -- to me, it just makes sense. It does what it needs to and nothing else. If OSGi was that unfriendly to legacy code, it would have never made it this far, particularly on the server side. -r.brown Heath :
I've been developing OSGi applications through the Eclipse RCP for about 4 years now. Its mostly been a very pleasant experience.
I agree with keeping OSGi feature-simple (as in, removing Require-Bundle). However, the functionality of Require-Bundle is what keeps Eclipse so easy to develop for. Since there is a one-to-one relationship between your plugin requirements and the plugin satisfying the requirements, its easy to look up code while developing and deploy required bundles while distributing. Eclipse does a very good job of helping the developer through the development and distribution process by detecting required bundles at launch-time and at build-and-assembly time. I hope that some standards could be included for these crucial points so that developers can have a common experience across containers. Keep up the good work, OSGi is a great model! -Heath Gunnar :
OSGi is great. Require-Bundle is a perfect example of a feature which could be easily avoided if the tooling would have been ready earlier. Maybe tooling is also an answer for getting legacy code to work?
Anyway, even if you get legacy code to work there is no guarantee for any success. Some (most?) legacy code is what it is no matter if it runs on OSGi or on any other container - a legacy of static stuff. Frankly, OSGi already has a model which supports legacy code very well. Just put everything into one bundle. Once you come over regretting bygone times you can start splitting the bundle and make it modular. ekke :
please stay simple ! this is the most attractive part of OSGI for me.
I'm developing an OSGI client/server ERP solution (Eclipse RCP, Eclipse Riena, Easybeans,...) alone the steps to combine some OSGI-based frameworks is hard because of * using require-bundle for common used bundles * fighting with "core" bundles including 20 or more jars the best is to keep it simple: * use import/export whereever possible * use required-bundle (if really neded) only inside the scope of a framework, but never for 'standard' open source jars tooling is the key to help developers to build a good OSGI architecture, so from my opinion use tooling to help integrating legacy code or as gunnar said: put it into a bundle ekke Chris Aniszczyk (zx) :
Please keep things as simple as possible (in the core). It's the main thing that is attractive about OSGi...
For example, keep those JEE guys at bay and not introducing scoped classloaders... and other crazy things that aren't needed. Richard :
My company is seriously looking at OSGi for our next-generation product architecture. I love the ability to expose only API packages, and to explicitly declare bundle dependencies. We do, however, have the requirement to be able to have "application bundles" contribute classes and configuration to a "persistence bundle" that uses Hibernate. Without Require-Bundle, what is the proposed mechanism to allow the application bundles to access Hibernate CG proxy classes (as described in another blog post)? It is complex enough to use Hibernate with OSGi, but if you make it impossible by removing Require-Bundle, then OSGi will no longer be a candidate technology for our product.... I wish there were a way to keep developers from abusing Require-Bundle, but completely removing it would not be the way if it is still necessary for Hibernate support, for example.
Peter :
Please get one thing straight: we will not remove anything. Backward compatibility is very important for the OSGi.
Interestingly, you illustrate the problem quite well. There is no intrinsic need for a Object-Relational mapping tool to require Require-Bundle. The problem is that hibernate was build with a linear class path in mind. It is perfectly possible to create a much more modular (imho therefore better) solution to the ORM problem that does NOT require all the hoops and tricks needed to run hibernate (and many other linear classpath based solutions) on OSGi. People are attracted to OSGi because it addresses many of the problems with Java's linear class path. We have been able to keep it lean and mean as well (27 classes, which are mostly small interfaces). Should we change the spec (for the worse, at least will become significantly more complex and less safe) to accommodate Hibernate or will Hibernate (or a competitor) make a version that leverages OSGi's strengths? I guess that is the $1000 question :-( About application bundles ... watch this space. People are pressuring me to outline my view about this. Kind regards, Peter Kriens Chris Aniszczyk (zx) :
Richard, an alternative to Hibernate which is already OSGi friendly is EclipseLink. It was born out of Oracle's TopLink product and open-sourced to the community. It just hit its 1.0 release so you may want to evaluate it if you're in the need of a persistence solution for OSGi.
|
Registration OpenMarch 26 to 29 in Reston, VA, USARead the OSGi Blog ...
|
|||
|
Home | Trademark Policy | Privacy Policy Copyright © 2012 OSGi™ Alliance. Comments about the site? Send them to: OSGi Alliance WebMaster. |