Right, OBR seems the way to go. However, if not you can find useful
source code in
http://www2.osgi.org/svn/public/trunk/org.osgi.impl.bundle.bindex
http://www.aQute.biz/repo/biz/aQute/bndlib
Kind regards,
Peter Kriens
FM> Hi Olivier,
FM> Have you looked into using the OSGi Bundle Repository for this ? The RFC
FM> spec is here [1] and Apache Felix has a nice implementation of it at
FM> [2]. You might also want to look at Peter's blog entry at [3].
FM> After having set up such a repository, the bundlerepository bundle takes
FM> away all your pains of resolving dependencies and automatically include
FM> them for deployment.
FM> Hope this helps.
FM> Regards
FM> Felix
FM> [1] http://www2.osgi.org/download/rfc-0112_BundleRepository.pdf
FM> [2] http://svn.apache.org/repos/asf/felix/trunk/bundlerepository
FM> [3] http://www.osgi.org/blog/2006/04/bundle-repository.html
FM> Am Mittwoch, den 04.07.2007, 21:08 +0100 schrieb Pernet, Olivier:
>> Hi,
>>
>> I'm trying to retrieve all dependencies of a particular bundle, to be
>> able to create a new JVM, start an OSGi framework in there and install
>> my bundle and its dependencies.
>> I've come up with something using the PackageAdmin service, but it feels
>> really hackish. My main pain point is that there seem to be no way to
>> get all imported packages for a bundle (please prove me wrong here!)
>>
>> So, here's my solution (untested yet, I thought I'd ask before wasting
>> time in case there's something better):
>>
>> private List retrieveDaemonBundleDependencies() {
>> // List<Bundle>
>> List dependencies = new ArrayList();
>>
>> // Eeek.
>> // No other way to get imported packages (?)
>> Dictionary dict = daemonBundle.getHeaders();
>> String importsString = (String)
>> dict.get(Constants.IMPORT_PACKAGE);
>> String[] imports = importsString.split(",");
>> for (int i=0; i<imports.length; i++) {
>> String[] nameAndAttrs = imports[i].split(";");
>> String packageName = nameAndAttrs[0].trim();
>> dependencies.add(getExportingBundle(packageName));
>> }
>>
>> return dependencies;
>> }
>>
>> private Bundle getExportingBundle(String packageName) {
>> ExportedPackage[] exportedPackages =
>> packageAdmin.getExportedPackages(packageName);
>> for (int i=0; i<exportedPackages.length; i++) {
>> if (contains(exportedPackages[i].getImportingBundles(),
>> daemonBundle))
>> return exportedPackages[i].getExportingBundle();
>> }
>> throw new IllegalStateException("Exporting bundle not found for
>> package: " + packageName);
>> }
>>
>> private boolean contains(Object[] objects, Object o) {
>> for (int i=0; i<objects.length; i++)
>> if (objects[i].equals(o)) return true;
>> return false;
>> }
>>
>> Thanks for your help!
>>
>> _______________________________________________
>> OSGi Developer Mail List
>> [email protected]
>> http://www2.osgi.org/mailman/listinfo/osgi-dev
FM> _______________________________________________
FM> OSGi Developer Mail List
FM> [email protected]
FM> http://www2.osgi.org/mailman/listinfo/osgi-dev
--
Peter Kriens Tel +33467542167
9C, Avenue St. Drézéry AOL,Yahoo: pkriens
34160 Beaulieu, France ICQ 255570717
Skype pkriens Fax +1 8153772599
_______________________________________________
OSGi Developer Mail List
[email protected]
http://www2.osgi.org/mailman/listinfo/osgi-dev