Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Should PDE cache startup state of bundles?
Should PDE cache startup state of bundles? [message #66600] Fri, 12 May 2006 12:33 Go to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

I saw an odd issue this morning ... when starting up an Eclipse (RCP) application, a bundle is started manually with bundle.start() in the code (it's using services, so there's no specific dependency between the two). On the first run, this works fine, but on the second run it says that the bundle is already started. Cleaning the workspace doesn't seem to make any difference.

Exporting it as a product and running with a fresh standalone eclipse.exe doesn't exhibit this behaviour.

Should this be regarded as a bug in PDE? If so, I'll file a bug report about it ...

Alex.
Re: Should PDE cache startup state of bundles? [message #66642 is a reply to message #66600] Fri, 12 May 2006 22:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: neil.integility.com

Alex,

It's not a bug, it's a feature!

Sorry, always wanted to say that...

Seriously though, the start state of an OSGi bundle is meant to be
persistent. To override this, use the -clean runtime switch (or set
osgi.clean=true).

Regards
Neil
Re: Should PDE cache startup state of bundles? [message #66682 is a reply to message #66642] Sat, 13 May 2006 08:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

Odd. I thought I tried it with the -clean, and it still remembered the persisted state. Also, when exporting and running as a standalone product (without the osgi.clean), it didn't remember the startup state. So I'm still confused as to which one is the bug :-)

I can see this causing a lot of headaches for PDE users that are used to testing out services. If it remembers the startup state of the bundles, then you can have something that works fine in an existing launch configuration, but then fails if you create a new launch configuration or exporting the product, especially since the -clean appears to have no effect (seems to be caching it in the configuration/ instead of the workspace/ directory).

Alex.
Re: Should PDE cache startup state of bundles? [message #67998 is a reply to message #66682] Wed, 24 May 2006 18:38 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
First of all, a bundle will always be persistently started if it was
activated using Bundle#start in a previous session of Equinox (OSGi).
The only way to prevent that is to make sure you call Bundle#stop on the
bundles which you have explicitly started when your bundle is being
stopped during the shutdown process.

There are cases where you want to make sure a bundle is activated on
demand as you need them but you do not want them to be automatically
activated on next restart. This is a concept we call "lazy activation".
In order to use this feature of Equinox your "lazy activated" bundles
must have the following bundle manifest header specified

Eclipse-LazyStart: true

This header specifies that a bundle should be activated on first class
load if it has not already been explicitly activated. If a bundle is
activated lazily as a result of a class load (not by calling
Bundle#start) then the bundle will not be persistently marked for
activation on the next session of Equinox. This works well when you
have a natural class dependency between your bundles and you want the
bundles only activated the first time they are used. For example, when
an extension is constructed from you bundle to act upon a menu item. In
some cases that natural class dependency does not exist but you still
want to lazily activate a bundle. In this case you need to use the
Bundle#loadClass method to force a class load from the bundle you want
started instead of Bundle#start.

HTH

Tom
Re: Should PDE cache startup state of bundles? [message #68091 is a reply to message #67998] Wed, 24 May 2006 20:17 Go to previous message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

Just for other readers ... for Eclispe 3.1, it's Eclipse-LazyStart. For 3.2+, it's Eclipse-AutoStart IIRC.

Secondly, this approach works when you've got a class dependency, but doesn't work when you've got a service dependency, which is where the example came from. In that case, you don't have a direct class dependency so you have to start it manually to bring the service on line (of course, when the declarative services stuff goes live, you can use that instead).

Still, good summary of the information for anyone else that needs to know.

Alex.
Previous Topic:handling jar: URLS?
Next Topic:[server] get bundle inside a servlet
Goto Forum:
  


Current Time: Thu Apr 25 14:24:35 GMT 2024

Powered by FUDForum. Page generated in 0.02791 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top