There are cases where a bundle either does not have any imported services,
or wishes to execute behavior that does not depend upon its imported
services. Since SAT makes the BundleActivator methods
start(BundleContext) and stop(BundleContext)
final, the methods start() and stop() are
provided for this purpose. For example, a bundle that wishes to open a
window when it starts and close the window when it stops could implement
the following methods:
protected void start() {
ClientFeatureAdminWindow window = getWindow();
window.open();
}
protected void stop() {
ClientFeatureAdminWindow window = getWindow();
window.close();
}
start() is always called exactly once when the
bundle is started. The method activate(), on the other
hand, is called whenever all the bundle's imported services have been
acquired. While the start() method is only called once,
the activate() method can be called multiple times.
stop() is always called exactly once when the
bundle is stopped. The method deactivate(), on the other
hand, is called whenever the bundle no longer has acquired all of its
imported services. While the stop() method is only called
once, the deactivate() method can be called multiple times.
Copyright © 2001, 2007 IBM Corporation and others. All Rights Reserved.