> Hi folks, > > I just played a bit with the OSGi update mechanism and have a question > about the object references after the update process. > > I've updated one of my OSGi bundles and could see, that after calling > the "refresh" command not only the updated bundle has been restarted > but also all other bundles, that had object references to classes of > this bundle. That means that the internal states of all objects (not > only the one belonging to the updated bundle) have been reset. Could > you please comment this. >
Did you read the documentation for the PackageAdmin.refreshPackages method? Reading the spec and the javadoc will explain how refresh works. > A second question: what if my application is in the middle of a long > running method/operation and the refresh command will be called? What > will happen to the long running operation and the corresponding > object? Will the update command wait till the method will finish or do > I have to expect/deal with unexpected behavior or do I need to create > BundleListener and delay the reset till my methods are finished? There is no magic here. Your bundle will need to be stopped and, if you have a BundleActivator, the BundleActivator.stop method will be called. If you use DS, then DS will respond to the bundle stop by deactivating all the components in the bundle. During this activity, your bundle needs to properly and orderly shutdown. If your code does not properly handle this, then your code may end up running with a deactivated BundleContext and, after refresh, a deactivated class loader since a refreshed bundle will get a new class loader. Both of these may lead to strange failures in your code. > > Regards, > Eugen > _______________________________________________ > 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
