You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Bengt Rodehav <be...@rodehav.com> on 2011/02/22 10:33:05 UTC

iPOJO - "require at least one"

I'm using iPOJO to keep track of all the notification providers installed in
my application:

*@Component(managedservice = "seco.notification.service", name =
> "seco.notification.service", public_factory = false)
> **@Provides(specifications = INotificationService.class, strategy =
> "SERVICE")
> **public class NotificationService implements INotificationService {
> **
> **  @Requires(optional = true, nullable = false)
> **  private INotificationProvider[] mProviders;*



Whenever a notification shall be issued, I iterate over each of the
providers and have them issue notifications. However, I would like to make
sure that at least one provider is installed. Is there a way to make iPOJO
require at least one provider before publishing the service (the
INotificationService)?

/Bengt

Re: iPOJO - "require at least one"

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/22 Clement Escoffier <cl...@gmail.com>

>
>
> On 22.02.11 10:33, "Bengt Rodehav" <be...@rodehav.com> wrote:
>
> >I'm using iPOJO to keep track of all the notification providers installed
> >in
> >my application:
> >
> >*@Component(managedservice = "seco.notification.service", name =
> >> "seco.notification.service", public_factory = false)
> >> **@Provides(specifications = INotificationService.class, strategy =
> >> "SERVICE")
> >> **public class NotificationService implements INotificationService {
> >> **
> >> **  @Requires(optional = true, nullable = false)
> >> **  private INotificationProvider[] mProviders;*
> >
> >
> >
> >Whenever a notification shall be issued, I iterate over each of the
> >providers and have them issue notifications. However, I would like to make
> >sure that at least one provider is installed. Is there a way to make iPOJO
> >require at least one provider before publishing the service (the
> >INotificationService)?
>
> What about removing optional=true ? The others solutions is to play with
> the service controller (initialize to false if the array is empty).
>
> Regards,
>
> Clement
>
> >
> >/Bengt
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: iPOJO - "require at least one"

Posted by Bengt Rodehav <be...@rodehav.com>.
That worked beautifully - I guess I should have thought of that myself...

Thanks,

/Bengt

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

>
>
> On 22.02.11 10:33, "Bengt Rodehav" <be...@rodehav.com> wrote:
>
> >I'm using iPOJO to keep track of all the notification providers installed
> >in
> >my application:
> >
> >*@Component(managedservice = "seco.notification.service", name =
> >> "seco.notification.service", public_factory = false)
> >> **@Provides(specifications = INotificationService.class, strategy =
> >> "SERVICE")
> >> **public class NotificationService implements INotificationService {
> >> **
> >> **  @Requires(optional = true, nullable = false)
> >> **  private INotificationProvider[] mProviders;*
> >
> >
> >
> >Whenever a notification shall be issued, I iterate over each of the
> >providers and have them issue notifications. However, I would like to make
> >sure that at least one provider is installed. Is there a way to make iPOJO
> >require at least one provider before publishing the service (the
> >INotificationService)?
>
> What about removing optional=true ? The others solutions is to play with
> the service controller (initialize to false if the array is empty).
>
> Regards,
>
> Clement
>
> >
> >/Bengt
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: iPOJO - "require at least one"

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

On 22.02.11 10:33, "Bengt Rodehav" <be...@rodehav.com> wrote:

>I'm using iPOJO to keep track of all the notification providers installed
>in
>my application:
>
>*@Component(managedservice = "seco.notification.service", name =
>> "seco.notification.service", public_factory = false)
>> **@Provides(specifications = INotificationService.class, strategy =
>> "SERVICE")
>> **public class NotificationService implements INotificationService {
>> **
>> **  @Requires(optional = true, nullable = false)
>> **  private INotificationProvider[] mProviders;*
>
>
>
>Whenever a notification shall be issued, I iterate over each of the
>providers and have them issue notifications. However, I would like to make
>sure that at least one provider is installed. Is there a way to make iPOJO
>require at least one provider before publishing the service (the
>INotificationService)?

What about removing optional=true ? The others solutions is to play with
the service controller (initialize to false if the array is empty).

Regards,

Clement

>
>/Bengt



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