My experiments today.

Goal: Be able to install Karaf features within clerezza

Approach: use the service org.apache.karaf.features.FeaturesService provided by
the bundle Apache Karaf :: Features :: Core
(org.apache.karaf.features.core) [1].

Unfortunately this bundle has quite some dependencies which need to be
satisfied. I've chosen a brute force approach and installed the list
of bundles of the karaf-framework feature. Because of chicken and egg
I can't yet install features. So  I needed the following scala on the
command line:

import java.net._
val url = new 
URL("mvn:org.apache.karaf.assemblies.features/standard/2.3.0/xml/features")
val conn = url.openConnection
import xml._
val doc = XML.load(conn.getInputStream)

for (b <- doc\"feature"\"bundle") {
 val mvnUri = b.text
 try {
 val bundle = bundleContext.installBundle(mvnUri)
 bundle.start()
 } catch {
   case ex => out.println("Exception installing bundle", ex)
 }
}

The bundle org.apache.karaf.features.core is now satisfied but not
exposing any service. For some reason the blueprint service bundle
wasn't activated, activating it over the webconsole made the service
available. As new packages aren't avaiable on already open shells I
have to reconnect via ssh.

Now I can access the service:

zz>val fs = $[org.apache.karaf.features.FeaturesService]
fs: org.apache.karaf.features.FeaturesService =
org.apache.karaf.features.internal.FeaturesServiceImpl@9d8957d
zz>fs.[TAB]
addRepository           asInstanceOf            getFeature
 installFeature          installFeatures         isInstalled
  isInstanceOf            listFeatures
listInstalledFeatures   listRepositories        removeRepository
 restoreRepository       toString                uninstallFeature
  validateRepository
zz>fs.listFeatures
res0: Array[org.apache.karaf.features.Feature] = Array()
zz>fs.listRepositories
res1: Array[org.apache.karaf.features.Repository] = Array()

The next step will be to add a repository.

Reto

1. Thanks to Krzysztoffor pointing me to this:
http://mail-archives.apache.org/mod_mbox/karaf-user/201302.mbox/%3C2960186.kKK1vM5F7L%40dracula%3E

Reply via email to