karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanknez <jonathank...@hotmail.com>
Subject Starting resolved bundles once dependencies installed
Date Tue, 05 Dec 2017 18:30:23 GMT
I have a written a framework and a collection of plugins for said framework.
The framework is installed as a karaf feature. Each plugin is installed via
the normal "bundle:install -s mvn:xxx" command. When you install the
framework then the plugins everything works.

If you uninstall the framework feature, the plugins go back to a *resolved*
state. This makes perfect sense because they depend on bundles in the
framework feature.

If you install the framework feature again, it installs correctly but the
plugins remain in the *resolved* state. I would rather have them start
automatically instead of sitting in the resolved state. Is there a clean way
to tell karaf to go re-evaluate resolved bundles now that something new has
been installed?

So far I have found two workarounds for this.

1. Place the plugin bundles into the service mix *deploy* folder. For some
reason, this causes them to get properly restarted after the framework
feature is installed. I am not sure why this behaves differently then doing
a bundle:install at the command prompt.

2. Add code to my feature to use the BundleContext to get all the bundles
that are not active and start the ones that have my company name in the
symbolic name. Its a hack but it works.

I am looking for a more elegant solution. Any ideas?

For future generations, here is the code from workaround #2

public class MyClass {
   public void activate (BundleContext bc) {
      for(Bundle bundle: bc.getBundles()) {
         if (Bundle.ACTIVE != bundle.getState()) {
            if(bundle.getSymbolicName().contains("mycompanyname")) {
               try {
               catch (BundleException e1) {

Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

View raw message