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
|