Hi everyone,
I'm wondering how exactly the conditionals are supposed to be used in
Karaf features:


  <feature name="example" version="1.2.3">
    <conditional>
      <condition>xy</condition>
      ...
    </conditional>
    ...
  </feature>


I'm trying to activate a feature (or a list of bundles in that feature)
only if another feature specified in a condition is already installed.

I got this working alright, since I install these features dynamically
with some code anyway, but while it works, I am worried about potential
side-effects since I don't quite know how it is supposed to be working.

A simplified pseudo-code version of my code looks like this:


  // get installed features
  installedFeatures = featuresService.listInstalledFeatures()
  // iterate over available features
  for (Feature feature : featuresService.listFeatures()) {
    // get all conditions
    conditions = feature.getConditionals().getConditions()
    // check if a condition matches an installed feature
    if (conditions intersect installedFeatures) {
      // install feature
      featuresService.installFeature(feature);
    }
  }


Does anyone know if this could have any side-effects?

Or even better, can anyone give me a proper explanation or
documentation of how the conditionals in Karaf features work and how
they are supposed to be used?

Thanks,
Lars

Reply via email to