Hi,

Marc Speck schrieb:
Thanks for your time, Carsten and Christopher. I used Christopher's pom.xml
for the sling.samples.simple-demo as described above. This gives me still
errors in the console, see pom and output below.

I have to admit, this starts looking very nasty. For a starter you might just do something like this:

   <Import-Package>*;resolution:=optional</Import-Package>

This causes the bnd tool to mark each and every import as optional. This should at least get you a starter.



On a general note, I have serious doubts about this approach of OSGi. I
mean, we are talking here only about using a single library! I wonder how
cumbersome really complicate things get?

The problem is not OSGi by itself. Or as another developer stated: "I always thought I would develop modular libraries until I started doing OSGi bundles".

The problem really are legacy libraries providing support/bindings for tons of other libraries. Mixing and matching these things is a horrible and sometimes timeconsuming task. Because not all bindings are always needed.

So in your use case I would start like that:

  (1) Embed the Abdera libraries plus commons-code in a bundle
  (2) Create the bundle
  (3) Dump the headers of the bundle by just feeding the
      bundle to the bnd tool:
          $ java -jar bnd.jar my.bundle.jar
  (4) Look at the import statements and decide what to do:
        -> accept some (mostly stuff available from sling)
        -> decide required ones: add to the embed list and start
           over at step (2)
        -> decide unneeded ones (probably com.sun.* ?): mark as
           optional and start over at step (2)


Marking a dependency optional comes in two ways: (1) You may set the resolution optional by declaring the resolution:=optional directive in the Import-Package element/header or (2) you may list the package (wildcards allowed) in the DynamicImport-Package element header.

For example to dynamically resolve any com.sun package you could say:

     <DynamicImport-Package>com.sun.*</DynamicImport-Package>


Hope this helps a bit further ... and looking forward to hearing more about your experiences turning Abdera into OSGi-bundles.


Regards
Felix

Reply via email to