When the framework is launched it is working its way though the start-levels until the beginning start-level is reached.  When you stop the system bundle you are basically setting the start-level to 0 which stops all bundles and then shutsdown the framework.  The specification states the following:

<spec>
If the Framework is currently involved in changing the active start level, it must first reach the previously requested start level before it is allowed to continue with a newly requested start level. For example, assume the active start level is 5 and the Framework is requested to transition to start level 3. Before start level 3 is reached, another request is made to transition to start level 7. In this case, the OSGi Framework must first complete the transition to start level 3 before it transitions to start level 7.
</spec>

So in this case the framework is being launch and is changing the active start level to the beginning start-level.  This beginning start-level must be reached before allowing the next active start-level change (in order to stop the framework).  This is why you see all the other bundles attempting to start.

What you need to do is lower the beginning start-level to be the same value as the start-level of this "start-up" bundle.  Then this bundle should set the start-level to the final start-level if it is successful or stop the system bundle on failure.

Tom

[email protected] wrote: -----

To: OSGi - Dev <[email protected]>
From: Andrea Zoppello <[email protected]>
Sent by: [email protected]
Date: 03/09/2011 09:21AM
Subject: [osgi-dev] Is it possible to stop the framework inside an Activator start method?

Hi all,

Is it possible to stop the framework inside a bundle activator start method?

I'm asking this, because i need to have a bundle ( that i configure to
start ) with startup
level lower than other that need to do some configuration steps (
setting properties, prepare resources
and so on )

My need is to stop the framework and exit if something goes wrong in
this so called start-up bundle.

1) I've try to do get a reference to the system bundle and to stop by
doing this:

Bundle mainBundle = context.getBundleContext().getBundle(0);
mainBundle.stop();

but this seem don't work ( i seeequinox simple configurator continue to
process the bundle list ).

2) Another thing i try is to call the System.exit(0), it works but i
don't know if it's correct...

Which is the cleanest and right way to proceed in that case??

Andrea

_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to