You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Milen Dyankov <mi...@gmail.com> on 2014/10/13 12:02:08 UTC

iPOJO and ManagedServiceFactory

Hi,
can someone point me to an example of using ConfigAdmin's
ManagedServiceFactory with iPOJO components, please?

The reason I'm asking is, what the docs  (
http://felix.apache.org/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-advanced-topics/combining-ipojo-and-configuration-admin.html)
say:

 For each (public) component type, a ManagedServiceFactory is published.
> For each configurations matching with the component type from the
> Configuration Admin, a new component instance is created.


does not seem to work for me (iPOJO 1.12.0 in Karaf 3.0.1). No matter what
I do, I can't get a "org.osgi.service.cm.ManagedServiceFactory" registered
for my component.

iPOJO will register "org.osgi.service.cm.ManagedService" for the component
if I provide "managedservice = ..... " in the @Component and @Instantiate
it! In such case I can indeed use ConfigAdmin to configure the instance.

However I couldn't figure out how to instruct iPOJO to register a  "
ManagedServiceFactory" so that I can later on create new component
instances from ConfigAdmin. Am I misinterpreting the docs? Missing
something obvious?

Regards,
Milen


-- 
http://about.me/milen

Re: iPOJO and ManagedServiceFactory

Posted by "Guillaume Sauthier (OW2)" <gu...@gmail.com>.
Just use @Component(name=“your-new-pid")

-- 
Guillaume Sauthier (OW2)
Sent with Airmail

On 14 Oct 2014 at 09:25:14, Milen Dyankov (milendyankov@gmail.com) wrote:

Thank you Clement,  

It works now! I suppose there is no really a easy way to change the factory  
PID in this case, right?  

Regards,  
Milen  

On Mon, Oct 13, 2014 at 3:22 PM, Clement Escoffier <  
clement.escoffier@gmail.com> wrote:  

> Hi,  
>  
> On 13 octobre 2014 at 13:35:49, Milen Dyankov (milendyankov@gmail.com)  
> wrote:  
> Thank you for clarifying Clement!  
>  
> The goal it pretty simple. Say I have:  
>  
> @Component(  
> immediate = true,  
> managedservice = "my.service")  
> @Provides  
> public class MyServiceImpl implements MyService {  
>  
> @Property  
> protected String someProperty;  
> ...  
> }  
>  
> I would like to be able to able to create new instances (register new  
> services) by just creating respective my.service-unique_name.cfg files in  
> karaf's etc folder. This does not seem to work and up until now I thought  
> it's because the ManagedServiceFactory was not created. But if understand  
> correctly what you are saying - it should still work just use a different  
> approach internally. If that is correct, then must be something else I'm  
> doing wrong. I would appreciate any example (a pointer to a project using  
> something similar is more than enough) to learn from.  
>  
>  
> Remove the ‘managedservice’ attribute exposing a ManagedService and not  
> creating new instances. To create new instances, just create a cfg file  
> with the given name:  
>  
> MyServiceImplQualifiedName-id.cfg  
>  
> The “MyServiceImplQualifiedName” is the qualified name of your class (like  
> org.acme.component.MyServiceImpl)  
>  
> Regards,  
>  
> Clement  
>  
>  
>  
>  
>  
> Regards,  
> Milen  
>  
>  
>  
>  
>  
> On Mon, Oct 13, 2014 at 1:10 PM, Clement Escoffier <  
> clement.escoffier@gmail.com> wrote:  
>  
> > Hi,  
> >  
> > You are right, 1.12.0 does not expose ManagedServiceFactory anymore  
> > because it uses a ‘configuration tracker’  
> > (org.apache.felix.ipojo.ConfigurationTracker). The documentation is not  
> up  
> > to date. However, the feature stay the same. Factory configurations  
> pushed  
> > in the config admin create instances et support dynamic reconfiguration.  
> >  
> > Depending of what you want to do, you can also rely on the Factory  
> service  
> > exposed for each @Component.  
> >  
> > Cheers,  
> >  
> > Clement  
> >  
> > On 13 octobre 2014 at 12:02:36, Milen Dyankov (milendyankov@gmail.com)  
> > wrote:  
> >  
> > Hi,  
> > can someone point me to an example of using ConfigAdmin's  
> > ManagedServiceFactory with iPOJO components, please?  
> >  
> > The reason I'm asking is, what the docs (  
> >  
> >  
> http://felix.apache.org/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-advanced-topics/combining-ipojo-and-configuration-admin.html  
>  
> > )  
> > say:  
> >  
> > For each (public) component type, a ManagedServiceFactory is published.  
> > > For each configurations matching with the component type from the  
> > > Configuration Admin, a new component instance is created.  
> >  
> >  
> > does not seem to work for me (iPOJO 1.12.0 in Karaf 3.0.1). No matter  
> what  
> > I do, I can't get a "org.osgi.service.cm.ManagedServiceFactory"  
> registered  
> > for my component.  
> >  
> > iPOJO will register "org.osgi.service.cm.ManagedService" for the  
> component  
> > if I provide "managedservice = ..... " in the @Component and  
> @Instantiate  
> > it! In such case I can indeed use ConfigAdmin to configure the instance.  
> >  
> > However I couldn't figure out how to instruct iPOJO to register a "  
> > ManagedServiceFactory" so that I can later on create new component  
> > instances from ConfigAdmin. Am I misinterpreting the docs? Missing  
> > something obvious?  
> >  
> > Regards,  
> > Milen  
> >  
> >  
> > --  
> > http://about.me/milen  
> >  
>  
>  
>  
> --  
> http://about.me/milen  
>  



--  
http://about.me/milen  

Re: iPOJO and ManagedServiceFactory

Posted by Milen Dyankov <mi...@gmail.com>.
Thank you Clement,

It works now! I suppose there is no really a easy way to change the factory
PID in this case, right?

Regards,
Milen

On Mon, Oct 13, 2014 at 3:22 PM, Clement Escoffier <
clement.escoffier@gmail.com> wrote:

> Hi,
>
> On 13 octobre 2014 at 13:35:49, Milen Dyankov (milendyankov@gmail.com)
> wrote:
> Thank you for clarifying Clement!
>
> The goal it pretty simple. Say I have:
>
> @Component(
> immediate = true,
> managedservice = "my.service")
> @Provides
> public class MyServiceImpl implements MyService {
>
> @Property
> protected String someProperty;
> ...
> }
>
> I would like to be able to able to create new instances (register new
> services) by just creating respective my.service-unique_name.cfg files in
> karaf's etc folder. This does not seem to work and up until now I thought
> it's because the ManagedServiceFactory was not created. But if understand
> correctly what you are saying - it should still work just use a different
> approach internally. If that is correct, then must be something else I'm
> doing wrong. I would appreciate any example (a pointer to a project using
> something similar is more than enough) to learn from.
>
>
> Remove the ‘managedservice’ attribute exposing a ManagedService and not
> creating new instances. To create new instances, just create a cfg file
> with the given name:
>
> MyServiceImplQualifiedName-id.cfg
>
> The “MyServiceImplQualifiedName” is the qualified name of your class (like
> org.acme.component.MyServiceImpl)
>
> Regards,
>
> Clement
>
>
>
>
>
> Regards,
> Milen
>
>
>
>
>
> On Mon, Oct 13, 2014 at 1:10 PM, Clement Escoffier <
> clement.escoffier@gmail.com> wrote:
>
> > Hi,
> >
> > You are right, 1.12.0 does not expose ManagedServiceFactory anymore
> > because it uses a ‘configuration tracker’
> > (org.apache.felix.ipojo.ConfigurationTracker). The documentation is not
> up
> > to date. However, the feature stay the same. Factory configurations
> pushed
> > in the config admin create instances et support dynamic reconfiguration.
> >
> > Depending of what you want to do, you can also rely on the Factory
> service
> > exposed for each @Component.
> >
> > Cheers,
> >
> > Clement
> >
> > On 13 octobre 2014 at 12:02:36, Milen Dyankov (milendyankov@gmail.com)
> > wrote:
> >
> > Hi,
> > can someone point me to an example of using ConfigAdmin's
> > ManagedServiceFactory with iPOJO components, please?
> >
> > The reason I'm asking is, what the docs (
> >
> >
> http://felix.apache.org/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-advanced-topics/combining-ipojo-and-configuration-admin.html
>
> > )
> > say:
> >
> > For each (public) component type, a ManagedServiceFactory is published.
> > > For each configurations matching with the component type from the
> > > Configuration Admin, a new component instance is created.
> >
> >
> > does not seem to work for me (iPOJO 1.12.0 in Karaf 3.0.1). No matter
> what
> > I do, I can't get a "org.osgi.service.cm.ManagedServiceFactory"
> registered
> > for my component.
> >
> > iPOJO will register "org.osgi.service.cm.ManagedService" for the
> component
> > if I provide "managedservice = ..... " in the @Component and
> @Instantiate
> > it! In such case I can indeed use ConfigAdmin to configure the instance.
> >
> > However I couldn't figure out how to instruct iPOJO to register a "
> > ManagedServiceFactory" so that I can later on create new component
> > instances from ConfigAdmin. Am I misinterpreting the docs? Missing
> > something obvious?
> >
> > Regards,
> > Milen
> >
> >
> > --
> > http://about.me/milen
> >
>
>
>
> --
> http://about.me/milen
>



-- 
http://about.me/milen

Re: iPOJO and ManagedServiceFactory

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,

On 13 octobre 2014 at 13:35:49, Milen Dyankov (milendyankov@gmail.com) wrote:
Thank you for clarifying Clement! 

The goal it pretty simple. Say I have: 

@Component( 
immediate = true, 
managedservice = "my.service") 
@Provides 
public class MyServiceImpl implements MyService { 

@Property 
protected String someProperty; 
... 
} 

I would like to be able to able to create new instances (register new 
services) by just creating respective my.service-unique_name.cfg files in 
karaf's etc folder. This does not seem to work and up until now I thought 
it's because the ManagedServiceFactory was not created. But if understand 
correctly what you are saying - it should still work just use a different 
approach internally. If that is correct, then must be something else I'm 
doing wrong. I would appreciate any example (a pointer to a project using 
something similar is more than enough) to learn from. 


Remove the ‘managedservice’ attribute exposing a ManagedService and not creating new instances. To create new instances, just create a cfg file with the given name:

MyServiceImplQualifiedName-id.cfg

The “MyServiceImplQualifiedName” is the qualified name of your class (like org.acme.component.MyServiceImpl)

Regards,

Clement





Regards, 
Milen 





On Mon, Oct 13, 2014 at 1:10 PM, Clement Escoffier < 
clement.escoffier@gmail.com> wrote: 

> Hi, 
> 
> You are right, 1.12.0 does not expose ManagedServiceFactory anymore 
> because it uses a ‘configuration tracker’ 
> (org.apache.felix.ipojo.ConfigurationTracker). The documentation is not up 
> to date. However, the feature stay the same. Factory configurations pushed 
> in the config admin create instances et support dynamic reconfiguration. 
> 
> Depending of what you want to do, you can also rely on the Factory service 
> exposed for each @Component. 
> 
> Cheers, 
> 
> Clement 
> 
> On 13 octobre 2014 at 12:02:36, Milen Dyankov (milendyankov@gmail.com) 
> wrote: 
> 
> Hi, 
> can someone point me to an example of using ConfigAdmin's 
> ManagedServiceFactory with iPOJO components, please? 
> 
> The reason I'm asking is, what the docs ( 
> 
> http://felix.apache.org/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-advanced-topics/combining-ipojo-and-configuration-admin.html 
> ) 
> say: 
> 
> For each (public) component type, a ManagedServiceFactory is published. 
> > For each configurations matching with the component type from the 
> > Configuration Admin, a new component instance is created. 
> 
> 
> does not seem to work for me (iPOJO 1.12.0 in Karaf 3.0.1). No matter what 
> I do, I can't get a "org.osgi.service.cm.ManagedServiceFactory" registered 
> for my component. 
> 
> iPOJO will register "org.osgi.service.cm.ManagedService" for the component 
> if I provide "managedservice = ..... " in the @Component and @Instantiate 
> it! In such case I can indeed use ConfigAdmin to configure the instance. 
> 
> However I couldn't figure out how to instruct iPOJO to register a " 
> ManagedServiceFactory" so that I can later on create new component 
> instances from ConfigAdmin. Am I misinterpreting the docs? Missing 
> something obvious? 
> 
> Regards, 
> Milen 
> 
> 
> -- 
> http://about.me/milen 
> 



-- 
http://about.me/milen 

Re: iPOJO and ManagedServiceFactory

Posted by Milen Dyankov <mi...@gmail.com>.
Thank you for clarifying Clement!

The goal it pretty simple. Say I have:

@Component(
immediate = true,
managedservice = "my.service")
@Provides
public class MyServiceImpl implements MyService {

@Property
protected String someProperty;
...
}

I would like to be able to able to create new instances (register new
services) by just creating respective my.service-unique_name.cfg files in
karaf's etc folder. This does not seem to work and up until now I thought
it's because the ManagedServiceFactory was not created. But if understand
correctly what you are saying - it should still work just use a different
approach internally. If that is correct, then must be something else I'm
doing wrong. I would appreciate any example (a pointer to a project using
something similar is more than enough) to learn from.

Regards,
Milen





On Mon, Oct 13, 2014 at 1:10 PM, Clement Escoffier <
clement.escoffier@gmail.com> wrote:

> Hi,
>
> You are right, 1.12.0 does not expose ManagedServiceFactory anymore
> because it uses a ‘configuration tracker’
> (org.apache.felix.ipojo.ConfigurationTracker). The documentation is not up
> to date. However, the feature stay the same. Factory configurations pushed
> in the config admin create instances et support dynamic reconfiguration.
>
> Depending of what you want to do, you can also rely on the Factory service
> exposed for each @Component.
>
> Cheers,
>
> Clement
>
> On 13 octobre 2014 at 12:02:36, Milen Dyankov (milendyankov@gmail.com)
> wrote:
>
> Hi,
> can someone point me to an example of using ConfigAdmin's
> ManagedServiceFactory with iPOJO components, please?
>
> The reason I'm asking is, what the docs (
>
> http://felix.apache.org/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-advanced-topics/combining-ipojo-and-configuration-admin.html
> )
> say:
>
> For each (public) component type, a ManagedServiceFactory is published.
> > For each configurations matching with the component type from the
> > Configuration Admin, a new component instance is created.
>
>
> does not seem to work for me (iPOJO 1.12.0 in Karaf 3.0.1). No matter what
> I do, I can't get a "org.osgi.service.cm.ManagedServiceFactory" registered
> for my component.
>
> iPOJO will register "org.osgi.service.cm.ManagedService" for the component
> if I provide "managedservice = ..... " in the @Component and @Instantiate
> it! In such case I can indeed use ConfigAdmin to configure the instance.
>
> However I couldn't figure out how to instruct iPOJO to register a "
> ManagedServiceFactory" so that I can later on create new component
> instances from ConfigAdmin. Am I misinterpreting the docs? Missing
> something obvious?
>
> Regards,
> Milen
>
>
> --
> http://about.me/milen
>



-- 
http://about.me/milen

Re: iPOJO and ManagedServiceFactory

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,

You are right, 1.12.0 does not expose ManagedServiceFactory anymore because it uses a ‘configuration tracker’ (org.apache.felix.ipojo.ConfigurationTracker). The documentation is not up to date. However, the feature stay the same. Factory configurations pushed in the config admin create instances et support dynamic reconfiguration.

Depending of what you want to do, you can also rely on the Factory service exposed for each @Component.

Cheers,

Clement

On 13 octobre 2014 at 12:02:36, Milen Dyankov (milendyankov@gmail.com) wrote:

Hi,  
can someone point me to an example of using ConfigAdmin's  
ManagedServiceFactory with iPOJO components, please?  

The reason I'm asking is, what the docs (  
http://felix.apache.org/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-advanced-topics/combining-ipojo-and-configuration-admin.html)  
say:  

For each (public) component type, a ManagedServiceFactory is published.  
> For each configurations matching with the component type from the  
> Configuration Admin, a new component instance is created.  


does not seem to work for me (iPOJO 1.12.0 in Karaf 3.0.1). No matter what  
I do, I can't get a "org.osgi.service.cm.ManagedServiceFactory" registered  
for my component.  

iPOJO will register "org.osgi.service.cm.ManagedService" for the component  
if I provide "managedservice = ..... " in the @Component and @Instantiate  
it! In such case I can indeed use ConfigAdmin to configure the instance.  

However I couldn't figure out how to instruct iPOJO to register a "  
ManagedServiceFactory" so that I can later on create new component  
instances from ConfigAdmin. Am I misinterpreting the docs? Missing  
something obvious?  

Regards,  
Milen  


--  
http://about.me/milen