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. It is probably more straightforward for the instance to be activated first and then registered as a service.
The main reason for (non-factory) components to be registered before being activated is to allow for lazy loading of the component class (and dependent classes). With a factory component, there is no need for this since the call to newInstance must immediately load the component class. Since there is no opportunity for laziness, activation before registration makes sense. -- BJ Hargrave Senior Technical Staff Member, IBM OSGi Fellow and CTO of the OSGi Alliance hargr...@us.ibm.com office: +1 386 848 1781 mobile: +1 386 848 3788 From: Daniel Faber <m...@daniel-faber.de> To: osgi-dev@mail.osgi.org Date: 2011/06/03 07:41 Subject: [osgi-dev] Spec: DS factory component activation Sent by: osgi-dev-boun...@mail.osgi.org Hello! I read the DS spec in OSGi 4.2 Compendium and I probably didn't understand the following detail about factory components: 112.5.5 says: “The service registration must take place before the component configuration is activated. Service unregistration must take place before the component configuration is deactivated.” That seems to be consistent with 112.2.4: “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.” But in Figure 112.4 “register” comes after “activate” which is – as far as I understand – a contradiction of the rules quoted above. Also in 112.5.5, below figure 112.4, there's this sentence: “This method [newInstance] must create, satisfy and activate a new component configuration and register its component instance as a service if the component description specifies a service.” Although this does not define an order explicitly, the order of “activate” and “register” in this sentence corresponds to figure 112.4. So my question is: If a component provides a service and a component factory is used, what should happen first after a call to newInstance, activation or registration? If it is registration, then I don't understand why it is useful to register a component as a service although it has not been activated. Isn't there a chance that an uninitialized component instance is used as a service in this case? Or is it similar to delayed components, where the component will be activated as soon as another bundle actually requests the service? Regards, Daniel [attachment "signature.asc" deleted by BJ Hargrave/Austin/IBM] _______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev