Hi Felix

Sorry for the delay in responding...

>> Yet, here is the problem: The Service is not unregistered from the
>> ServiceRegistry, thus Bundle B1 is not informed about the instance Cb1
>> being deactivated.

My understanding is that when a ComponentInstance has its dispose() method 
called the component's provided services must be unregistered from the 
Service Registry.  So, if you are seeing registered service from a 
disposed component then that would be a bug in the DS implementation that 
you are using. I just tested this scenario on Equinox and it worked for 
me.  Which are you using?

I checked the spec and here's what I found. I believe that this backs up 
what I am saying. I have marked the most important bits in bold, so I hope 
that the formatting is not lost.

112.2.4 Factory Component
...
New configurations of the component can be created and activated by 
calling the newInstance method on this Component Factory service. The 
newInstance(Dictionary) method has a Dictionary object as argument. This 
Dictionary object is merged with the component properties as described in 
Component Properties on page 326. If the component specifies a service, 
then the service is registered after the created component configuration 
is satisfied with the component properties. Then the component 
configuration is activated.
...
A new service will be registered each time a new component configuration 
is created and activated with the newInstance method. This allows a bundle 
other than the one creating the component configuration to utilize the 
service. If the component configuration is deactivated, the service must 
be unregistered.
...
112.12.6 public interface ComponentInstance
...
public void dispose( )
Dispose of the component configuration for this component instance. The 
component configuration will be deactivated. If the component 
configuration has already been deactivated, this method does nothing.

I hope this helps,

Simon



From:
Felix Meschberger <[email protected]>
To:
OSGi Developer Mail List <[email protected]>
Date:
11/27/2009 02:59 PM
Subject:
Re: [osgi-dev] [DS] Question regarding CompoinentInstance for service 
factory components
Sent by:
[email protected]



Hi,

Thanks for your response.

Yet I am not sure, whether I was clear enough in my question. Let me
rephrase it with an example:

Consider a service factory Component C. Bundles B1 and B2 have acquired
the service, this they get object instances (configurations) Cb1 and
Cb2. These two instances are backed a ComponentInstance Cib1 and Cib2.

Question is: What happens when dispose() is called on ComponentInstance
Cib1 ?

Option 1 would be, that Component C is disposed off and thus instances
Cb1 and Cb2.

Option 2 would be, that only instance Cb1 is disposed off. If I
understand the spec correctly, this would be the intended way of the spec.

Yet, here is the problem: The Service is not unregistered from the
ServiceRegistry, thus Bundle B1 is not informed about the instance Cb1
being deactivated.

We can say: no problem, because only Bundle B1 can get at the
ComponentInstance Cib1 and thus can take precautions on this situation.

Does this sound right an/or understandable ?

Thanks and Regards
Felix

Simon J Archer schrieb:
> 
>>From reading the spec the second option seems correct.
> 
> I agree that (2) is the correct behavior.  It would never occur to me to
> wish for (1).
> 
>>>But thinking this through in my understanding this means
>>>to deactivate an object which has been distributed to
>>>consumers by the service registry without informing the
>>>service registry about that fact.
> 
> When a ComponentInstance is disposed any services provided by the DS
> component are unregistered and removed from the OSGi service registry
> before the component is deactivated. Of course, the unregistration of a
> service will likely affect other DS components, and so on up the
> dependency tree.
> 
> 
> From:                  Felix Meschberger <[email protected]>
> To:            OSGi Developer Mail List <[email protected]>
> Date:                  11/23/2009 10:19 AM
> Subject:               [osgi-dev] [DS] Question regarding 
CompoinentInstance for
> service        factory components
> Sent by:               [email protected]
> 
> 
> ------------------------------------------------------------------------
> 
> 
> 
> Hi all,
> 
> While discussing the development of a Management/Administrative API for
> DS we came across a problem with respect to the
> ComponentInstance.dispose() method when applied to an instance of a
> service factory component.
> 
> There are basically two options:
> 
> (1) dispose() applies to the component as a whole. That is the
>     service is unregistered and all component instances are
>     disposed off.
> 
> (2) dispose() applies only to the component instance (object) on whose
>     ComponentInstance object the method has been called.
> 
>>From reading the spec the second option seems correct. But thinking this
> through in my understanding this means to deactivate an object which
> has been distributed to consumers by the service registry without
> informing the service registry about that fact.
> 
> Thanks for any help.
> 
> Regards
> Felix
> 
> _______________________________________________
> 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
_______________________________________________
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

Reply via email to