> > For a factory component instance created (and activated) with 
> > newInstance, it does not really matter whether the instance is 
> > activated before it is registered as a service or not.
> 
> I don't understand why it doesn't matter.  If the instance is registered
> first, then bundles can retrieve a not yet activated component instance
> via the service registry.  Since activation includes running the
> activate method which may perform important initialization tasks, I
> think it should be required to activate the component instance first.

Well, the DS impl would need to make sure any users of the service did not 
receive an unactivated instance. This can be done like it is done for 
non-factory components: by using a ServiceFactory to delay having to 
provide the actual service instance. But there is not point in doing this 
for factory components since that must be activated by the newInstance 
method.

> > Since there is no opportunity for laziness, activation before
> > registration makes sense.
> 
> Yes, I agree it makes sense, but I would go even further and think the
> spec must require it for the reason stated above.
> 

Well the spec does effectively state it. newInstance must create and 
activate the component instance. So there is no point in a DS impl using a 
ServiceFactory to delay activation. But it is free to do so.

> But even if I miss an important point here, the spec should IMHO do one
> of three things:
> 
> (1) require activation before registration
> (2) require registration before activation
> (3) let the order explicitly undefined
> 
> As I wrote in my first mail, the spec seems to do (1) at some places and
> (2) at some other places.
> 

I don't see any issues with the spec. It is quite clear that newInstance 
must activate the instance immediately. Whether a DS impl actually 
registers before or after activation is not relevant. But the DS impl must 
never expose the non-activated instance to anyone. Both the caller to 
newInstance must see an activated instance and anyone getting the 
registered service must also see an activated instance. The observed 
behavior is specified. To specify how the DS impl must achieves that is 
over specification.


-- 

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance
[email protected]

office: +1 386 848 1781
mobile: +1 386 848 3788
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to