1

Today I came across a situation when I updated bundle however the program continued working as there was no any changes in code. After some reading I understood that I have to do osgi refresh - the following code (found on SO):

Bundle systemBundle = bundleContext.getBundle(0);
FrameworkWiring frameworkWiring = systemBundle.adapt(FrameworkWiring.class);
frameworkWiring.refreshBundles(null);

So my question - when should I do osgi refresh? Only after update? After each bundle update or I can update N bundles and after that do refresh?

Pavel_K
  • 10,748
  • 13
  • 73
  • 186

1 Answers1

1

OSGi refresh needs to be done when you want OSGi to reinitialize wirings between packages. Usually this is needed after upgrading/downgrading some bundle's version.

You may find also useful: What do these OSGi commands really do?

or I can update N bundles and after that do refresh?

If not deeping into details, that's the answer to your question. In practice, I observed situations when some frameworks which are not well adopted to OSGi, may cause ClassLoader memory leaks at the time of refresh, so be careful.

Community
  • 1
  • 1
skapral
  • 1,128
  • 9
  • 26