You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Jean-Baptiste Reich <je...@gmail.com> on 2011/02/21 16:26:33 UTC

iPOJO with a singleton component managed by Config Admin

Hello,

I am reading the iPOJO documentation but I don't see how I can handle the
creation of a singleton component when a configuration in config admin is
there.
My problem is to wait until a configuration is available for a given pid and
to create the unique instance of my component at that moment.

I have seen that I could declare a factory on my component which results in
the creation of a ManagedServiceFactory but with that I can't limit the
number of instances...

Another way is to declare a private component with a pid and to declare my
single instance in the metadata.xml but like this my object is created even
if I don't have configuration in config admin...

Is there a way to do that ?

Thanks

Re: iPOJO with a singleton component managed by Config Admin

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

On 22.02.11 11:25, "Jean-Baptiste Reich" <je...@gmail.com>
wrote:

>Thank you for your answer.
>
>I can't use annotations so I guess that I can declare my component in the
>metadata.xml like this:
>
><component classname="test.MyService" name="MyService" public="false">
>    <provides />
>    <properties pid="test.MyService">
>
>       ...
>
>    </properties></component>
>
>
><instance ...>
>
></instance>
>
>
>But in the xml file we do not specify if it is a ManagedService or a
>ManagedServiceFactory ? How can I know which service is registered ?

In the above xml files, only the managed service will be registered as the
factory is not public. You set the managed service pid to test.MyService.
Note that managed service and managed service factories cannot have the
same pid.

If you want, you can also specify the managed service pid in your instance
declaration:
<instance component="...MyComponent">
  <property name="managed.service.pid" value="my.pid"/>
</instance>


Regards,

Clement

>
>
>Thank you
>
>
>2011/2/21 Clement Escoffier <cl...@gmail.com>
>
>> Hi,
>>
>> On 21.02.11 16:26, "Jean-Baptiste Reich" <je...@gmail.com>
>> wrote:
>>
>> >Hello,
>> >
>> >I am reading the iPOJO documentation but I don't see how I can handle
>>the
>> >creation of a singleton component when a configuration in config admin
>>is
>> >there.
>> >My problem is to wait until a configuration is available for a given
>>pid
>> >and
>> >to create the unique instance of my component at that moment.
>> >
>> >I have seen that I could declare a factory on my component which
>>results
>> >in
>> >the creation of a ManagedServiceFactory but with that I can't limit the
>> >number of instances...
>> >
>> >Another way is to declare a private component with a pid and to
>>declare my
>> >single instance in the metadata.xml but like this my object is created
>> >even
>> >if I don't have configuration in config admin...
>> >
>> >Is there a way to do that ?
>>
>> You can also expose a ManagedService using:
>> @Component(managedservice=pid, publicFactory=false)
>>
>> Where pid is the desired managed service pid.
>>
>> Regards,
>>
>> Clement
>>
>> >
>> >Thanks
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: iPOJO with a singleton component managed by Config Admin

Posted by Jean-Baptiste Reich <je...@gmail.com>.
Thank you for your answer.

I can't use annotations so I guess that I can declare my component in the
metadata.xml like this:

<component classname="test.MyService" name="MyService" public="false">
    <provides />
    <properties pid="test.MyService">

       ...

    </properties></component>


<instance ...>

</instance>


But in the xml file we do not specify if it is a ManagedService or a
ManagedServiceFactory ? How can I know which service is registered ?


Thank you


2011/2/21 Clement Escoffier <cl...@gmail.com>

> Hi,
>
> On 21.02.11 16:26, "Jean-Baptiste Reich" <je...@gmail.com>
> wrote:
>
> >Hello,
> >
> >I am reading the iPOJO documentation but I don't see how I can handle the
> >creation of a singleton component when a configuration in config admin is
> >there.
> >My problem is to wait until a configuration is available for a given pid
> >and
> >to create the unique instance of my component at that moment.
> >
> >I have seen that I could declare a factory on my component which results
> >in
> >the creation of a ManagedServiceFactory but with that I can't limit the
> >number of instances...
> >
> >Another way is to declare a private component with a pid and to declare my
> >single instance in the metadata.xml but like this my object is created
> >even
> >if I don't have configuration in config admin...
> >
> >Is there a way to do that ?
>
> You can also expose a ManagedService using:
> @Component(managedservice=pid, publicFactory=false)
>
> Where pid is the desired managed service pid.
>
> Regards,
>
> Clement
>
> >
> >Thanks
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: iPOJO with a singleton component managed by Config Admin

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

On 21.02.11 16:26, "Jean-Baptiste Reich" <je...@gmail.com>
wrote:

>Hello,
>
>I am reading the iPOJO documentation but I don't see how I can handle the
>creation of a singleton component when a configuration in config admin is
>there.
>My problem is to wait until a configuration is available for a given pid
>and
>to create the unique instance of my component at that moment.
>
>I have seen that I could declare a factory on my component which results
>in
>the creation of a ManagedServiceFactory but with that I can't limit the
>number of instances...
>
>Another way is to declare a private component with a pid and to declare my
>single instance in the metadata.xml but like this my object is created
>even
>if I don't have configuration in config admin...
>
>Is there a way to do that ?

You can also expose a ManagedService using:
@Component(managedservice=pid, publicFactory=false)

Where pid is the desired managed service pid.

Regards,

Clement

>
>Thanks



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org