You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Cristiano Ghersi <cr...@abodata.com> on 2013/01/30 18:07:20 UTC

Hot swap of bundles and class reloading

Hi all,

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

Re: Hot swap of bundles and class reloading

Posted by Neil Bartlett <nj...@gmail.com>.
Rather than posting exactly the same question to both the equinox and felix mail lists, it would be better to ask general OSGi questions on the osgi-dev list: http://www.osgi.org/MailLists/HomePage 

Regards,
Neil

-- 
Neil Bartlett
Sent from a phone


On Wednesday, 30 January 2013 at 17:07, Cristiano Ghersi wrote:

> Hi all,
> 
> 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