felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From BJ Hargrave <hargr...@us.ibm.com>
Subject Re: Contribution of the dependency manager to Feli
Date Mon, 30 Jan 2006 21:21:11 GMT
Karl Pauls <karlpauls@gmail.com> wrote on 2006-01-30 03:41:42 PM:

> > I think that by implementing the change you suggest above
> > (requiring volatile) the problem is solved.
> Unfortunately, this doesn't solve your problem (at least not in regard
> to the old java memory model). This has changed in 1.5 and yes, the
> new one would solve your issues in regard to the reference - still it
> doesn't solve the initialization problem (i.e., while the reference is
> guaranteed to be volatile - get and set is atomic - one could still
> hit the situation where the fields of the Service are not
> initialized).

But that is a problem for the service implementation to deal with: that is 
the service implementation must be thread safe. All that the dependency 
manager needs to be responsible for is to provide a reference to the 
service object in a thread safe way. The work the service implementation 
needs to do to be thread safe is independent of whether dependency manager 
is used to provide the service object to a client. The service object 
should be properly initialized before dependency manager has a reference 
to it and a well designed service should not have field accessible to 
clients. If the data of the service is only accessible via method calls, 
the service implementation can take the proper action to ensure thread 

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance
Office: +1 407 849 9117 Mobile: +1 386 848 3788

View raw message