Definitely.

I'm not sure it's explained very well anywhere, but what you probably want is 
factory configurations, not factory components (which are nearly useless as 
described by the spec).  I strongly recommend setting up metatype to document 
what the configuration your DS component expects should look like.  In the 
metatype designate, specify factory-pid rather than pid.  Then create multiple 
configurations using this factory pid.  Each one will result in a separate 
instance of your DS component, using the properties you specified in the 
factory configuration.  The metatype is not essential but IMO really helps 
document what you are doing.  I don't know what support karaf has for metatype.

I'm not sure how to create the factory configurations in karaf, I use a very 
different (proprietary) framework for managing configurations.  Your 
description of what you are doing sounds vaguely familiar so it might be the 
correct way.

If you use felix ds trunk and bnd master you can use some really nifty new ds 
1.3/metatype 1.3 features where the configuration is delivered to your DS 
component as an annotation  instance, and you can annotation the annotation to 
generate the metatype.

Factory components mean that you need to create each instance of your DS 
component in code by calling componentInstance.newInstance(props).  This is not 
very declarative any longer.  The spec lifecycle for these things makes them 
almost useless.  In fellx ds trunk you can specify per-component a flag that 
makes the iifecycle act just like a component created from a CA Configuration.  
However, you almost certainly just want plain DS components with factory 
configurations.

I very very strongly recommend setting the configuration-policy to REQUIRE.  
Factory configurations with OPTIONAL (the default) act really strangely and in 
my experience create problems that no one can figure out the cause of.

hope this helps….. I follow the felix lists a little more than this one in case 
you get stuck and I don't seem to be replying.

david jencks

On Apr 17, 2015, at 11:40 AM, lbu <lburgazz...@gmail.com> wrote:

> All,
> 
> I'm learning Declarative Services so I'm "upgrading" an application based on
> Karaf and Blueprint to DS and I'm having troubles understanding how to
> achieve the same or similar behavior:
> 
> I have a bundle which contains a service that is supposed to be instantiated
> multiple time with setup and with blueprint I do so by hot-deploying a
> number of blueprint file in xml, what I'd like to do with DS is creating a
> service for each configuration in ${karaf.home}/etc that matched a "prefix"
> like my.service-instance1, my.service-instance2, etc. I had a look at DS
> Component Factory but I do not know if it is the right option.
> 
> Do you think that my expected behavior can be implemented with DS ?  
> 
> Best regards,
> Luca
> 
> 
> 
> 
> --
> View this message in context: 
> http://karaf.922171.n3.nabble.com/Declarative-Services-with-Karaf-tp4039768.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to