2009/2/23 bank kus <[email protected]> > > I have 4 components ( OSGI bundles if you will ) A, B, C and D. Each > component has several modules depending upon how we want the > interfaces of that component to be bound to implementations. Heres the > dependency map: > > C ==> A ( this means Component C uses A ) > B ==> A > > D ==> B (therefore indirectly also uses A through B) > D ==> C (therefore indirectly also uses A through C) > D ==> A > > The modules exported from B ( or any component ) are self contained > i.e., they wire up all dependencies of B and B's dependencies which > means A. > > Heres the trouble, if I use a module for B and C that use different > versions of A the whole thing blows up. Likewise if D uses a module of > A thats different from B and C its the same. Is there a more elegant > way to solviing this? >
well it really depends what you mean by "the whole thing blows up", are you getting ClassCastExceptions or duplicate binding errors? if you want to enforce that everyone uses the same version of A and you are using OSGi then you could do this by using the right imports and exports, along with version constraints on imported packages. otherwise you could use a builder/assembler to ensure that everyone gets the same A. Hmm... sounds like a job for DI, meaning you could use Guice to inject modules across your application then use these modules to create the actual application injector. In real life its like saying I want to build a house with windows and > doors. The doors are made of mahogany wood but that doesnt mean my > windows should also be made up of mahogany wood. From the house > builders perspective I dont want to know what the doors and windows > are made up of its just a door and window I liked so I picked it up. now it sounds like you want private modules, ie. you actually don't want A to be the same across the application but instead you want to avoid the "blowing up" issue (ie. you want A kept private in B, C, and D) luckily private modules will be in Guice 2: http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/PrivateModule.html they're also available in the latest Guice snapshot HTH > -- Cheers, Stuart --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-guice?hl=en -~----------~----~----~----~------~----~------~--~---
