2

I'm facing the following issue under OSGi environment: let's say I have a bundle A exporting com.mybiz.example package. This package, in its 1.0.0 version, contains a bean class MyBean so that

public class MyBean {
 int var;
 public MyBean() { }
 public int getVar() { return var; }
 public void setVar(int v) { var = v; }
}

Bundle B exports an interface MyService which uses MyBean:

public interface MyService {
 public MyBean getMyBean();
}

Note: in our architecture, MyBean must be a class and not an interface.

Bundle C uses MyService as a declarative service in this way:

private AtomicReference<MyService> _serv = new AtomicReference<MyService>();
public void addMyService(MyService serv) {
 //this method is the one called by declarative services when Bundle B is started
 _serv.set(serv);
}

public void run() {
 ...

 MyBean x = _serv.getMyBean();
 //use x ...
}

Now the problem arises if I need to do a hot fix on MyBean class. Let's say I need to add a field and some methods. Then, I've got a running OSGi environment where bundles A,B,C are deployed.

My requirement is that I cannot stop any bundle.

So, under these hypotheses, I deploy a new version of my bundle A, say A_1.1.0.jar. Now I'm not able to make bundle C to use the new version of MyBean class contained in A_1.1.0.jar.

How can I do it?

Thank you very much!

Best regards

cghersi

Cristiano Ghersi
  • 1,944
  • 1
  • 20
  • 46

2 Answers2

2

Please refer to the answer BJ Hargrave gave you on the Equinox mailing list. I'll summarise BJ's answer for the sake of other StackOverflow users.

MyBean is part of the API or contract for the service, and bundles cannot simply reload an API on the fly. Bundle C must be stopped, refreshed/resolved, and then started again.

Neil Bartlett
  • 23,743
  • 4
  • 44
  • 77
0

AFAIK, you can't. Off the top of my head I think you have move bundle A to the INSTALLED state, whic probably also will put any dependencies to the INSTALLED state. Then you install your new version of the bundle and the resolve should then choose the new version.

But I might be wrong...

Puce
  • 37,247
  • 13
  • 80
  • 152