My point was that most of Karaf examples use features (as described in the README.md), so you can see there how to play with import packages and the way to write a Karaf feature.

Regards
JB

On 25/08/2021 11:36, Xad Kile wrote:
@Jean-Baptiste Onofre: I have been studying the official examples, but haven't figured out a way to make the whole building process painless. I must have missed something as I often do. But Steinar Bang's examples really show me the way. @Steinar Bang: OMG, your project gives me so much enlightenment, thanks a million times.

Thank you all so much for helping me overcome this block :D
Kile

On Tue, Aug 24, 2021 at 11:15 PM Steinar Bang <s...@dod.no <mailto:s...@dod.no>> wrote:

     >>>>> Jean-Baptiste Onofre <j...@nanthrax.net <mailto:j...@nanthrax.net>>:

     > Hi,
     > You can take a look on the karaf examples.

     > Basically, you have two options:

     > 1. You create a feature containing your module/bundle and the
    dependency bundles, playing with import package
     > 2. You create a uber bundle embedding the dependencies (private
    package or embed dependency)

     > The preferred approach is probably 1.

    FWIW, alternative 1 is my preferred approach.

    My applications consist of a cloud of bundles and a feature pulling them
    in (this let me "mix and match", ie. switch between production database
    and test database, and either pull in a dependency or have it be
    provided).

    Here's an example uber-feature:
    
https://github.com/steinarb/ukelonn/blob/master/karaf/src/main/filtered-resources/feature.xml#L16
    
<https://github.com/steinarb/ukelonn/blob/master/karaf/src/main/filtered-resources/feature.xml#L16>

    At the top it pulls in all of the feature reposiories that are built
    together with my OSGi bundles, and attached to the OSGi bundles
    (creating features and attaching them, is done by the
    karaf-maven-plugin).

    Then I create some high level features that I use to load the
    application in different configuration:
      1. ukelonn-with-derby loads the application with an in-memory test
         database with dummy data
      2. ukelonn-with-postgresql loads the application with a PostgreSQL
         database
      3. ukelonn-with-postgresql-and-provided-authservice expects an
         authservice application to already be loaded (authservice provides
         authentication and authorization using apache shiro)

Reply via email to