Hi all, I have got some general questions about starting and stopping bundles.
Given that I made my first OSGi steps with Knopflerfish, I have usually been following their general recommendations on bundle design:
http://www.knopflerfish.org/programming.html Starting:Konpflerfish seems to suggest to spawn a thread if bundle activation is supposed to take a while.
(See section "Spawning a startup thread"). This basically translates to the following construct:public void start(final BundleContext bundleContext) throws Exception {
c_BundleContext = bundleContext;
Thread t = new Thread(
new Runnable() {
public void run() {
///do start logic
}//run
}//Runnable
);//Thread
t.setContextClassLoader(getClass().getClassLoader());
t.start();
}//start
Is this approach recommendable? Are there side-effects that could be
container dependent?
Stopping:Knopflerfish seems to assume that when a bundle is stopped, the framework should be taking care about unregistering services.
(See "Automatic cleanup of services") Is this generally valid or container dependent?Also, does this also apply to Listener instances (like for example a ServiceListener) and service references that are being used? I.e. is there a need to call BundleContext.removeService/ FrameworkListener() or m_BundleContext.ungetService() for cleanup?
Any comments and answers are appreciated. Regards, Dieter
smime.p7s
Description: S/MIME cryptographic signature
