karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david.a.jen...@gmail.com>
Subject Re: How to prevent Declarative Service activation
Date Sun, 14 Apr 2019 15:56:24 GMT
Please distinguish between the state of a bundle and the state of a DS component.

I suggest that you have one (new) component, always enabled, that enables the other components
if appropriate. The DS model is not designed for components to control their own state or
existence.


David Jencks 

Sent from my iPhone

> On Apr 14, 2019, at 4:07 AM, kamilantlgc <kamil.pasko@antologic.com> wrote:
> 
> I want to prevent starting the bundle under certain circumstances (for
> example bundle did not authorize itself)
> 
> Javadoc of BundleActivator#start
> (https://osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleActivator.html)
> states:
> "If this method throws an exception, this bundle is marked as stopped and
> the Framework will remove this bundle's listeners, unregister all services
> registered by this bundle, and release all services used by this bundle."
> 
> One difference is, that I'm using Declarative Service approach instead of
> BundleActivator:
>  @Activate
>  public void start(final BundleContext ctx, final Map<String, Object>
> props) {
>    System.out.println("Starting...");
>    if(true) {
>      throw new RuntimeException("unauthorized");
>    }
>  }
> 
> But I thought it should behave in similar way. Unfortunately when I do:
> 301 | Resolved |  80 | 0.0.1          | My Bundle
> karaf@root()> bundle:start 301
> Starting...
> Starting...
> 
> The bundle:
> * Tries to activate TWO times (why?)
> * is in WAITING status (instead of RESOLVED)
> karaf@root()> bundle:list
> 301 | Waiting |  80 | 0.0.1          | My Bundle
> 
> And the worst thing is that when I invoke start for the second time:
> karaf@root()> bundle:start 301
> karaf@root()>
> * It does not do anything (nothing is printed in the console, it does not
> try to authorize for the second time)
> 
> Is this the right behavior of Karaf?
> If yes, then how can I programmatically prevent starting of the Declarative
> Service bundle?
> 
> Kind regards,
> Kamil
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Mime
View raw message