Hi Alexander,

Alexander Shutyaev schrieb:
> I have come upon a conceptual problem with OSGi.
> 
> First, I'll tell what I need. I need a factory that will create some
> instances. Each instance has it's own configuration and all instances
> provide a service.
> 
> I've read about the EMailFetcher example in the Configuration Admin
> Specification and it turned out to be just my case. So I was happy and
> thought that I should use ManagedServiceFactory and all the things
> associated with it.
> 
> Later, however I've read the Declarative Services Specification. And
> that is where it began. I can't feel the difference between the
> ManagedServiceFactory (from Configuration Admin) and ComponentFactory
> (from Declarative Services).
> 
> If anyone could tell me the difference between them (for example why
> can't I use ComponentFactory in the EMailFetcher example, or can I?), I
> would be very-very thankful.

I cannot tell you why you can't use the ComponentFactory for the
EMailFetcher. But from your explanation, the ComponentFactory is what
you need.

In the case of a ComponentFactory, the Declarative Services Runtime
creates a helper object for you which gets the configuration from the
Configuration Admin Service as would a ManagedServiceFactory. For each
configuration recevied, an actual instance of your component is created
and activated -- and registered as a service if required.

If an existing configuration is updated, the component instance is
stopped and started with the new configuration.

If the existing configuration is deleted, the respective component
instance is stopped and disposed off.

As an example have a look at the Apache Sling RequestLoggerService
(source is at [1]).

Hope this helps.
Regards
Felix


[1]
http://svn.apache.org/viewvc/incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/log/RequestLoggerService.java?view=markup
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to