felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bengt Rodehav <be...@rodehav.com>
Subject Re: iPojo problem: The mandatory property xyz is missing
Date Tue, 15 Nov 2016 07:25:41 GMT
OK - I'll remember that.

I do use Managed Service Factories a lot but when I'm dealing with a
singleton I normally use @instantiate. This is, however, the first time
where I have a property that cannot really have a sensible default value
which is why I set it to mandatory.

It feels a bit weird to use Managed Service Factories when dealing with a
singleton.

/Bengt

2016-11-13 20:56 GMT+01:00 Clement Escoffier <clement.escoffier@gmail.com>:

>
> > On 13 Nov 2016, at 14:46, Bengt Rodehav <bengt@rodehav.com> wrote:
> >
> > OK, thanks Clement.
> >
> > Out of interest, when would the combination @instantiate and mandatory
> work
> > / make sense?
>
> Never I would say ;-)
> There are many other way to declare instances in iPOJO such as Managed
> Service Factory, the iPOJO Factory service and so on. Mandatory is used in
> these contexts.
>
> Clement
>
>
> >
> > /Bengt
> >
> > Den 11 nov. 2016 2:52 em skrev "Clement Escoffier" <
> > clement.escoffier@gmail.com>:
> >
> >> Hi,
> >>
> >> No actually, it’s the expected behaviour. A mandatory property is
> required
> >> to be set when the instance is created.
> >>
> >> @Instantiate create an instance without any configuration, while you
> set a
> >> property to be mandatory. The property is injected by the config admin
> >> after the instance creation (as it’s a ManagedService configuration).
> >>
> >> So you have 2 choices:
> >>
> >> * either set the property to not mandatory and use the config admin to
> >> provide a value after the instantiation
> >> * use a ManagedServiceFactory configuration to instantiate the component
> >> (in this case remove the @Instantiate)
> >>
> >> Clement
> >>
> >>
> >>> On 10 Nov 2016, at 12:00, Bengt Rodehav <bengt@rodehav.com> wrote:
> >>>
> >>> Do you think this is a bug or haven't I fully understood how iPojo
> works
> >> in
> >>> this situation?
> >>>
> >>> /Bengt
> >>>
> >>> 2016-11-09 9:02 GMT+01:00 Bengt Rodehav <bengt@rodehav.com>:
> >>>
> >>>> Hello Clement,
> >>>>
> >>>> I instantiate the component as follows:
> >>>>
> >>>> @Component(managedservice = "hp.webservice", name = "hp.webservice",
> >>>>> publicFactory = false)
> >>>>> @Instantiate
> >>>>> public class HpWebService {
> >>>>> ...
> >>>>
> >>>>
> >>>> If I declare the property as mandatory, the instance never becomes
> valid
> >>>> at all. I thought it would be invalid until configuration manager gave
> >> the
> >>>> property a value and then it would become valid.
> >>>>
> >>>> /Bengt
> >>>>
> >>>>
> >>>> 2016-11-08 20:52 GMT+01:00 Clement Escoffier <
> >> clement.escoffier@gmail.com>
> >>>> :
> >>>>
> >>>>> Hi,
> >>>>>
> >>>>> The error means that you tried to create an instance of the component
> >>>>> with without the “logoBaseUrl” property. Do you know how this
> instance
> >> is
> >>>>> declared, and from where come the configuration ?
> >>>>>
> >>>>> Clement
> >>>>>
> >>>>>> On 8 Nov 2016, at 14:54, Bengt Rodehav <bengt@rodehav.com>
wrote:
> >>>>>>
> >>>>>> I'm using Karaf 4.0.7 with iPojo 1.12.1.
> >>>>>>
> >>>>>> I have declared a mandatory parameter as follows:
> >>>>>>
> >>>>>> @Property(name = "logoBaseUrl", mandatory = true)
> >>>>>>
> >>>>>>
> >>>>>> I have a configuration file for this property that sets the
proper
> >>>>> value of
> >>>>>> the property "logoBaseUrl".
> >>>>>>
> >>>>>> But, on startup I get:
> >>>>>>
> >>>>>> 2016-11-08 14:40:40,910 | ERROR |  pool-1-thread-1 | web
> >>>>>>>         | ?                                   ? | [ERROR]
> >>>>> hp.webservice
> >>>>>>> : The configuration is not acceptable : The mandatory property
> >>>>> logoBaseUrl
> >>>>>>> is missing
> >>>>>>
> >>>>>>
> >>>>>> And my iPojo component never becomes valid.
> >>>>>>
> >>>>>> If I change the property as follows:
> >>>>>>
> >>>>>> @Property(name = "logoBaseUrl", mandatory = false,
> >> value="/notvalidurl")
> >>>>>>
> >>>>>>
> >>>>>> Then everything works and the proper value is picked up from
my
> >>>>>> configuration file.
> >>>>>>
> >>>>>> It's like iPojo never waits for the component to become configured
> but
> >>>>>> fails immediately. I would like the iPojo component to wait
for the
> >>>>>> configuration and then become valid. How can I accomplish this?
> >>>>>>
> >>>>>> /Bengt
> >>>>>
> >>>>>
> >>>>> ------------------------------------------------------------
> ---------
> >>>>> 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
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message