Hi,

On 10.05.2010 20:04, Tom Kesling wrote:
> Hello,
> I'd like to know if there a recommendation/best practice for when to
> use a Component Factory over a POJO factory registered as a service?

I would say, it is a matter of taste and a decision on whether to use
Declarative Services or not.

For example since we use Declarative Services in our application, I
would go for the Component Factory solution.

If you don't use Declarative Services and don't plan on ever using it
(why ? You might want to consider ;-) ), the the POJO factory might be
more appropriate.

The advantage of using Declarative Services is, that you don't have to
care about dependencies of the factory instances or registering the
factory instances as services (if required). This is all handled by the
Declarative Services runtime.

> 
> I have a POJO factory for creating JMS connection factories that is
> registered as a service. This service is consumed by another bundle
> that is responsible for reading config data and then using the service
> to create factories.
> 
> I was considering turning this POJO into a Component Factory and I'd
> like to know if it makes sense to do so and/or what to consider to
> make this decision.
> 
> Also, I have not seen a way to use a Component Factory without (at
> some point) creating a dependency to osgi.  Is it possible to avoid
> this?

Yes and No.

>From the point of view of the factory, you don't need OSGi API because
the ComponentFactory service is managed by the Declarative Services
runtime. You just have to implement the class which is instantiated for
the actual JMS connection factories, which in turn does not require OSGi
API when using the Declarative Services 1.1 specification (R4.2 Compendium).

But to access the ComponentFactory service, you of course use OSGi API
first to get at the service and then to create component instances
calling the ComponentFactory.newInstance method.

Hope this helps.

Regards
Felix

> 
> 
> Thanks,
> T
> _______________________________________________
> 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