The problem with util bundles is that their transitive dependency has a tendency to swell. That would be no problem if the util bundle was cohesive but they rarely are. Example, I once debugged a case where about 20 Mb of external dependencies were dragged in because the developers used one two line method in Apache commons collection.
For this reason, bnd has the Conditional-Package instruction. This instruction is ignored while building the bundles but after the content is set, it will match any imports against this instruction. Any matching packages are copied to the bundle which is then reanalyzed until no more matching imported packages are found. For example: Private-Package: biz.aQute.whatever.impl.* Conditional-Package: biz.aQute.util.* Any imports from biz.aQute.util.* will automatically be included in your bundle in your private are. That is, these utils will not be shared. Many bundles can include the same package, one of the great advantages of OSGi over other Java module systems. Obviously this will create redundancy but it gives you less coupling, there is a of course a trade off. However, it is binary redundancy, the source code is still in one location. I find this Conditional-Package to be extremely effective for specially developed util jars. The model works best when the utils themselves are in separate packages, this allows you to pick and choose and not pay for unwanted dependencies. Kind regards, Peter Kriens On 1 dec 2010, at 00:51, Wesley Silva wrote: > Hi, > > I'm currently migrating an existing web application to OSGI. During the > process I saw the utility package, where there are classes to manipulate > things like date, strings, files, cryptography and so on. Almost all web > applications in my company have this kind of package so I was wondering if > it was a good idea to turn it into a reused piece of software. > So here is my question, is it a good idea to turn it into a bundle? If so, > how would this bundle look like? Would it publish some > service thought interfaces or just export packages? Any suggestions? > > -- > Att, > Wesley > MSc Candidate in Software Engineering > Specialist in Test Analisys (CIn/UFPE - Motorola) > B.S. in Computer science - UFS > Sun Certified Java Programmer > Sun Certified Web Component Developer > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev _______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev