Hi David,

I also thought about how to nicely deploy applications created by bndtools.
I think there are two general ways of using karaf

1. Server mode

You deploy several independent deployment units to karaf. This is for example used by Talend or Redhat to deploy many indepenent integrations into karaf. You use features to describe each deployment unit and use the shell or jmx to deploy them.

For this mode a solution could be to create an obr index for your application using the bnd-indexer-plugin. We think about adding an element to the feature.xml to reference such a repository. The features should then work in a similar way to bndrun files and just describe the top level bundles and requirements and let the resolver create the actual list of bundles to install.

We are also thinking about creating obr indexes for each open source project per release and deploy these to maven central. So you could create your application in bndtools by just combining existing
obr repository files.

Bndtools could also be adapted to be able to create and validate feature files. On the other hand we could adapt the karaf feature.xml to look more like a bndrun file. So for example if you already have an obr index to back your feature then each bundle requirement in the featue can be desribed like in bndrun using the symbolic name + optionally a version range. So this would make creating features a lot easier.

2. Application mode

In this case karaf typically hosts only one deployment unit. You want to start and most times also deploy your application together with karaf.

In most cases a karaf custom distribution is created during the application build. Here you have two choices to describe your application. The traditional way is to describe it as one or more features and add these to the boot features.

As bndtools can not create features but can create nice deployments from bndrun files we can also use another approach here. We could skip the whole feature service and describe karaf + your application as a plain list of bundles using startup.properties. Bndtools could supply this list and an enhanced karaf maven plugin could create the whole archive. I think this mode should be realtively easy to support using bndtools. It should also be possible to make the nice bndtools debug mode work with karaf.

Another advantage of the application approach would be that the static list of bundles is a very stable form of deployment. You can not have surprises like the feature service refreshing bundles or karaf trying to load artifacts from the internet.

As these concepts are not yet tested in the field I would be very interested in your feedback.

Christian

Am 26.11.2015 um 01:36 schrieb David Leangen:

Hi,

If it’s any help, I am also using bndtools in Eclipse/gradle. I am in a greenfield environment, so it is probably easier for me.

Thanks to the help of the kind people in this community, I was able to get my release process working. I do this by releasing my bundles from bndtools, then having Karaf pull in the bundles from that repository. I actually like this way of passing the baton, as it nicely decouples my development environment from my deployment environment, using the standard OBR repository as the intermediary.

My only remaining challenge is, since Karaf is centred around features, to figure out how to convert my bnd “application” bundle into a feature. This is the bundle that pulls in all the other necessary bundles based on direct and transient requirements. Clearly, the “application” bundle performs the same function as a Karaf feature, so this would be an interesting avenue to explore.

If possible this week I will experiment with adding a “Karaf Feature” capability to my application bundle, so that when the repository is installed, any bundle with this capability will be added to a corresponding feature, which would also get installed into the system. If this works as I expect, and if the community is interested, I could try to submit a pull request.

Getting back to the title, “Bndtools & Karaf : the right way”, I think that this would be the “right” way to do it. :-)


Cheers,
=David


On Nov 26, 2015, at 4:29 AM, [email protected] <mailto:[email protected]> wrote:

Yes agreed,

I have found that my reasons for leaving the maven-bundle-plugin were artificial. You do not need a custom package type because you can map the lifecycle steps yourself. You can still configure it for a bnd file and even if it imports by default you can manually configure it to exclude by default and set all your imports. What I was trying to get across was that there are a lot of great options out there for how to configure your environment and there is no "the right way". In my opinion karaf is maven centered where as bnd is centered on eclipse and its workspaces but they are coming together nicely. It may take some time to find the tools you like but there are a lot of really smart people out there that can help you get just the environment you like.


David Daniel


On 2015-11-25 14:20, Achim Nierbeck wrote:

Hi,
just for the record with the maven-bundle-plugin you can also use the bnd file, just configure the pom accordingly.
regards, Achim

2015-11-25 16:51 GMT+01:00 <[email protected] <mailto:[email protected]>>:

    I think different people handle things in different ways.  Most
    people who work on karaf seem to use the maven bundle plugin
    with pax-exam for testing.  The maven-bundle-plugin uses bnd
    tools underneath and just moves the configuration into your pom
    file instead of .bnd or .bndrun file.  What I have been moving
    to as a very beginner in karaf is the bnd-maven-plugin and
    bnd-indexer-plugin.  These allow for tighter integration with
    bnd tools but are really alpha in bnd tool 3.1  You have to get
    the builds from bnd tools ci and they don't have support for bnd
    tools running and packaging.  I also find myself taking all the
    features that I use from karaf and coping the information in
    there to bnd files so I can run test and package from bnd tools
    which is a lot of duplication of work.  Bnd Tools is working on
    adding better maven support but they are really built up around
    eclipse and gradle at this time.  I think you will have to find
    what works for you and what features you like.


    David Daniel


    On 2015-11-25 09:41, deadbrain wrote:

        Hi all  Karaf gurus,
        just a little question dealing with BndTools, I am supposed to refactor
        an existing Spring DM application into an OSGi + Blueprint application
        to be deployed inside ServiceMix (3.4 or 4). As a consequence I would
        like to use Bndtools but launching Karaf rather than the defaut Gogo
        shell would be more convenient.
          What is the best way to do that ?
        I am supposed to write or reuse an ApplicationFactory ? I found a couple
        of implementations in github (ready to use ?)
        Is there any other  valuable option?

        Kind regards
        Jerome



--

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
Software Architect / Project Manager / Scrum Master


Reply via email to