You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Cristiano Gavião <cv...@gmail.com> on 2016/06/27 21:42:24 UTC

doubt about component DS 1.3 with scope Prototype and ConfigurationPolicy.REQUIRE

Hello,

I'm facing a situation that I'm not understanding. I'm using 
org.apache.felix.scr 2.0.2.
I've set a component with this annotation:

    @Component(enabled = true, configurationPolicy =
    ConfigurationPolicy.REQUIRE,
             scope = ServiceScope.PROTOTYPE, service =
    FixedControllerService.class,
             configurationPid = {SERVICE_FACTORY_PID_CONTROLLER})

    <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
    name="com.c4biz.feast.ComponentControllerServiceProvider"
    configuration-policy="require" enabled="true" activate="activate"
    deactivate="deactivate" modified="modified"
    configuration-pid="fixed.controller">
       <implementation
    class="com.c4biz.feast.ComponentControllerServiceProvider"/>
       <service scope="prototype">
         <provide interface="com.c4biz.feast.FixedControllerService"/>
       </service>
    </scr:component>

In this component class I have a method (activate()) tagged with 
@Activate annotation. And there are any reference bind being used for now.

 From another bundle I'm creating a configuration using factoryPID = 
SERVICE_FACTORY_PID_CONTROLLER.
Interesting is that the service are being created and with in a proper 
autogenerated PID and passed properties. At least I can see it when 
listing the services using gogo console.

also scr:list tells me that the component is enabled and satisfied.

What I'm not understanding is that the activate method is not being 
called...

could someone explain me what am I missing here?

thanks,

Cristiano

Re: doubt about component DS 1.3 with scope Prototype and ConfigurationPolicy.REQUIRE

Posted by Cristiano Gavião <cv...@gmail.com>.
hummm... think I got the idea now...

I will create another component to consume the registered service and 
see if the activate method is being called...

thanks again,

Cristiano

On 27/06/2016 19:08, Neil Bartlett wrote:
>> On 27 Jun 2016, at 23:05, Cristiano Gavi�o <cv...@gmail.com> wrote:
>>
>> Thanks David and Neil,
>>
>> Humm, I don't think I understood yet.
>>
>> Ok, I don't have any other bundle/component consuming this service, yet.
>>
>> but in this case why I have an instance of the service that received the configuration from CM registered ?
> You don\u2019t have an instance\u2026 you have a service registration. When another bundle sees this in the service registry and calls getService(), then an instance of the class will be created in order to provide the service. This is a key laziness feature offered by DS.
>
> Regards,
> Neil
>
>
>> Look at the log below:
>>
>>    18:54:13.557 INFO : com.c4biz.feast.kernel.lib [ OSGI_BUNDLE ]:
>>    ServiceEvent REGISTERED
>>    [S:{com.c4biz.feast.FixedControllerService}={service.pid=fixed.controller-1467064453446-0,
>>    service.factoryPid=fixed.controller,
>>    component.name=com.c4biz.feast.ComponentControllerServiceProvider,
>>    extenderAlias=ConfigurationManifestHeaderExtender,
>>    targetBundleStateMask=32, component.id=4,
>>    targetTrackingMode=manifest_header, service.id=56,
>>    service.bundleid=18, service.scope=prototype}]
>>
>>
>>
>> On 27/06/2016 18:47, Neil Bartlett wrote:
>>> Probably lazy activation. Your component is a service, of type FixedControllerService. No instances will be created until a consumer binds to it.
>>>
>>> Neil
>>>
>>>
>>>> On 27 Jun 2016, at 22:42, Cristiano Gavi�o <cv...@gmail.com> wrote:
>>>>
>>>> Hello,
>>>>
>>>> I'm facing a situation that I'm not understanding. I'm using org.apache.felix.scr 2.0.2.
>>>> I've set a component with this annotation:
>>>>
>>>>    @Component(enabled = true, configurationPolicy =
>>>>    ConfigurationPolicy.REQUIRE,
>>>>             scope = ServiceScope.PROTOTYPE, service =
>>>>    FixedControllerService.class,
>>>>             configurationPid = {SERVICE_FACTORY_PID_CONTROLLER})
>>>>
>>>>    <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
>>>>    name="com.c4biz.feast.ComponentControllerServiceProvider"
>>>>    configuration-policy="require" enabled="true" activate="activate"
>>>>    deactivate="deactivate" modified="modified"
>>>>    configuration-pid="fixed.controller">
>>>>       <implementation
>>>>    class="com.c4biz.feast.ComponentControllerServiceProvider"/>
>>>>       <service scope="prototype">
>>>>         <provide interface="com.c4biz.feast.FixedControllerService"/>
>>>>       </service>
>>>>    </scr:component>
>>>>
>>>> In this component class I have a method (activate()) tagged with @Activate annotation. And there are any reference bind being used for now.
>>>>
>>>>  From another bundle I'm creating a configuration using factoryPID = SERVICE_FACTORY_PID_CONTROLLER.
>>>> Interesting is that the service are being created and with in a proper autogenerated PID and passed properties. At least I can see it when listing the services using gogo console.
>>>>
>>>> also scr:list tells me that the component is enabled and satisfied.
>>>>
>>>> What I'm not understanding is that the activate method is not being called...
>>>>
>>>> could someone explain me what am I missing here?
>>>>
>>>> thanks,
>>>>
>>>> Cristiano
>>> ---------------------------------------------------------------------
>>> 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


Re: doubt about component DS 1.3 with scope Prototype and ConfigurationPolicy.REQUIRE

Posted by Neil Bartlett <nj...@gmail.com>.
> On 27 Jun 2016, at 23:05, Cristiano Gavião <cv...@gmail.com> wrote:
> 
> Thanks David and Neil,
> 
> Humm, I don't think I understood yet.
> 
> Ok, I don't have any other bundle/component consuming this service, yet.
> 
> but in this case why I have an instance of the service that received the configuration from CM registered ?

You don’t have an instance… you have a service registration. When another bundle sees this in the service registry and calls getService(), then an instance of the class will be created in order to provide the service. This is a key laziness feature offered by DS.

Regards,
Neil


> 
> Look at the log below:
> 
>   18:54:13.557 INFO : com.c4biz.feast.kernel.lib [ OSGI_BUNDLE ]:
>   ServiceEvent REGISTERED
>   [S:{com.c4biz.feast.FixedControllerService}={service.pid=fixed.controller-1467064453446-0,
>   service.factoryPid=fixed.controller,
>   component.name=com.c4biz.feast.ComponentControllerServiceProvider,
>   extenderAlias=ConfigurationManifestHeaderExtender,
>   targetBundleStateMask=32, component.id=4,
>   targetTrackingMode=manifest_header, service.id=56,
>   service.bundleid=18, service.scope=prototype}]
> 
> 
> 
> On 27/06/2016 18:47, Neil Bartlett wrote:
>> Probably lazy activation. Your component is a service, of type FixedControllerService. No instances will be created until a consumer binds to it.
>> 
>> Neil
>> 
>> 
>>> On 27 Jun 2016, at 22:42, Cristiano Gavião <cv...@gmail.com> wrote:
>>> 
>>> Hello,
>>> 
>>> I'm facing a situation that I'm not understanding. I'm using org.apache.felix.scr 2.0.2.
>>> I've set a component with this annotation:
>>> 
>>>   @Component(enabled = true, configurationPolicy =
>>>   ConfigurationPolicy.REQUIRE,
>>>            scope = ServiceScope.PROTOTYPE, service =
>>>   FixedControllerService.class,
>>>            configurationPid = {SERVICE_FACTORY_PID_CONTROLLER})
>>> 
>>>   <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
>>>   name="com.c4biz.feast.ComponentControllerServiceProvider"
>>>   configuration-policy="require" enabled="true" activate="activate"
>>>   deactivate="deactivate" modified="modified"
>>>   configuration-pid="fixed.controller">
>>>      <implementation
>>>   class="com.c4biz.feast.ComponentControllerServiceProvider"/>
>>>      <service scope="prototype">
>>>        <provide interface="com.c4biz.feast.FixedControllerService"/>
>>>      </service>
>>>   </scr:component>
>>> 
>>> In this component class I have a method (activate()) tagged with @Activate annotation. And there are any reference bind being used for now.
>>> 
>>> From another bundle I'm creating a configuration using factoryPID = SERVICE_FACTORY_PID_CONTROLLER.
>>> Interesting is that the service are being created and with in a proper autogenerated PID and passed properties. At least I can see it when listing the services using gogo console.
>>> 
>>> also scr:list tells me that the component is enabled and satisfied.
>>> 
>>> What I'm not understanding is that the activate method is not being called...
>>> 
>>> could someone explain me what am I missing here?
>>> 
>>> thanks,
>>> 
>>> Cristiano
>> 
>> ---------------------------------------------------------------------
>> 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: doubt about component DS 1.3 with scope Prototype and ConfigurationPolicy.REQUIRE

Posted by Cristiano Gavião <cv...@gmail.com>.
Thanks David and Neil,

Humm, I don't think I understood yet.

Ok, I don't have any other bundle/component consuming this service, yet.

but in this case why I have an instance of the service that received the 
configuration from CM registered ?

Look at the log below:

    18:54:13.557 INFO : com.c4biz.feast.kernel.lib [ OSGI_BUNDLE ]:
    ServiceEvent REGISTERED
    [S:{com.c4biz.feast.FixedControllerService}={service.pid=fixed.controller-1467064453446-0,
    service.factoryPid=fixed.controller,
    component.name=com.c4biz.feast.ComponentControllerServiceProvider,
    extenderAlias=ConfigurationManifestHeaderExtender,
    targetBundleStateMask=32, component.id=4,
    targetTrackingMode=manifest_header, service.id=56,
    service.bundleid=18, service.scope=prototype}]



On 27/06/2016 18:47, Neil Bartlett wrote:
> Probably lazy activation. Your component is a service, of type FixedControllerService. No instances will be created until a consumer binds to it.
>
> Neil
>
>
>> On 27 Jun 2016, at 22:42, Cristiano Gavi�o <cv...@gmail.com> wrote:
>>
>> Hello,
>>
>> I'm facing a situation that I'm not understanding. I'm using org.apache.felix.scr 2.0.2.
>> I've set a component with this annotation:
>>
>>    @Component(enabled = true, configurationPolicy =
>>    ConfigurationPolicy.REQUIRE,
>>             scope = ServiceScope.PROTOTYPE, service =
>>    FixedControllerService.class,
>>             configurationPid = {SERVICE_FACTORY_PID_CONTROLLER})
>>
>>    <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
>>    name="com.c4biz.feast.ComponentControllerServiceProvider"
>>    configuration-policy="require" enabled="true" activate="activate"
>>    deactivate="deactivate" modified="modified"
>>    configuration-pid="fixed.controller">
>>       <implementation
>>    class="com.c4biz.feast.ComponentControllerServiceProvider"/>
>>       <service scope="prototype">
>>         <provide interface="com.c4biz.feast.FixedControllerService"/>
>>       </service>
>>    </scr:component>
>>
>> In this component class I have a method (activate()) tagged with @Activate annotation. And there are any reference bind being used for now.
>>
>>  From another bundle I'm creating a configuration using factoryPID = SERVICE_FACTORY_PID_CONTROLLER.
>> Interesting is that the service are being created and with in a proper autogenerated PID and passed properties. At least I can see it when listing the services using gogo console.
>>
>> also scr:list tells me that the component is enabled and satisfied.
>>
>> What I'm not understanding is that the activate method is not being called...
>>
>> could someone explain me what am I missing here?
>>
>> thanks,
>>
>> Cristiano
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>


Re: doubt about component DS 1.3 with scope Prototype and ConfigurationPolicy.REQUIRE

Posted by Neil Bartlett <nj...@gmail.com>.
Probably lazy activation. Your component is a service, of type FixedControllerService. No instances will be created until a consumer binds to it.

Neil


> On 27 Jun 2016, at 22:42, Cristiano Gavião <cv...@gmail.com> wrote:
> 
> Hello,
> 
> I'm facing a situation that I'm not understanding. I'm using org.apache.felix.scr 2.0.2.
> I've set a component with this annotation:
> 
>   @Component(enabled = true, configurationPolicy =
>   ConfigurationPolicy.REQUIRE,
>            scope = ServiceScope.PROTOTYPE, service =
>   FixedControllerService.class,
>            configurationPid = {SERVICE_FACTORY_PID_CONTROLLER})
> 
>   <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
>   name="com.c4biz.feast.ComponentControllerServiceProvider"
>   configuration-policy="require" enabled="true" activate="activate"
>   deactivate="deactivate" modified="modified"
>   configuration-pid="fixed.controller">
>      <implementation
>   class="com.c4biz.feast.ComponentControllerServiceProvider"/>
>      <service scope="prototype">
>        <provide interface="com.c4biz.feast.FixedControllerService"/>
>      </service>
>   </scr:component>
> 
> In this component class I have a method (activate()) tagged with @Activate annotation. And there are any reference bind being used for now.
> 
> From another bundle I'm creating a configuration using factoryPID = SERVICE_FACTORY_PID_CONTROLLER.
> Interesting is that the service are being created and with in a proper autogenerated PID and passed properties. At least I can see it when listing the services using gogo console.
> 
> also scr:list tells me that the component is enabled and satisfied.
> 
> What I'm not understanding is that the activate method is not being called...
> 
> could someone explain me what am I missing here?
> 
> thanks,
> 
> Cristiano


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


Re: doubt about component DS 1.3 with scope Prototype and ConfigurationPolicy.REQUIRE

Posted by Cristiano Gavião <cv...@gmail.com>.
Thanks again David, your (and Neil's) explanation help me to understand 
this concept much better now.

Interesting, I always thought that when declaring a component as 
Singleton we would have only one component and one instance of its 
service. but with the CM combination it can be very flexible...

and now I figured it out that in order to accomplish my task, having the 
activate method called as soon as the configuration factory pid is 
registered, what I had to do was: configurationPolicy = 
ConfigurationPolicy.REQUIRE,
         scope = ServiceScope.SINGLETON, immediate = true.

best regards,

Cristiano

On 27/06/2016 19:55, David Jencks wrote:
> I\u2019m not sure I\u2019m receiving all your replies\u2026.
>
> Most of the things you can specify for a DS component are completely independent, which makes it very powerful, but there are a couple that aren\u2019t and that can be confusing.
>
> It\u2019s unusual to need to specify enabled=false. I don\u2019t think I ever have.  It might be useful if some other component needs to set up an environment without which the disabled component doesn\u2019t make sense.
>
> Configuration policy and scope are independent.  Configuration policy is also somewhat confusing since whether you get one instance or many is determined by config admin, not DS.
>
> For instance if you are using a factory pid in config admin, you can get as many component configurations as you want, one for each configuration.  For each of those, the scope determines how many instances the configuration might have.  Singleton scope means you get at most one, and all requestors get the same service instance.  This is the only scope that is compatible with immediate.  Bundle scope means all requestors from the same bundle get the same instance, and requestors from different bundles get different instances.  Prototype scope means if you use the ServiceObjects interface you can get as many instances as you want.
>
> There\u2019s also stuff you can now do with multiple pids but maybe the above is enough for now\u2026.
>
> hope this helps
> david jencks
>
>> On Jun 27, 2016, at 3:32 PM, Cristiano Gavi�o <cv...@gmail.com> wrote:
>>
>> Sorry, my mistake...
>>
>> only now I understood what you have said about enable=true be the default value... :-[
>>
>> On 27/06/2016 19:16, Cristiano Gavi�o wrote:
>>>
>>> On 27/06/2016 18:48, David Jencks wrote:
>>>> You\u2019ve specified prototype scope, so there is never going to be \u201cONE\u201d canonical instance.  You need something to request the service from the service reference or from the ServiceObjects interface from the service reference.
>>>>
>>>> With the default scope, you aren\u2019t going to get an instance created without a user either unless you specify immediate=true as well.
>>> if I understood the spec right, when I use immediate=true then I get a Singleton scope, right?
>>>
>>> Would a component with scope singleton use ConfigurationPolicy.REQUIRE ?
>>>
>>>> I generally don\u2019t specify enabled=true since that is the default value.
>>> then you let your components as enabled=false and then will use a master component to enable the others ?
>>>
>>>> david jencks
>>>>
>>>>> On Jun 27, 2016, at 2:42 PM, Cristiano Gavi�o <cv...@gmail.com> wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> I'm facing a situation that I'm not understanding. I'm using org.apache.felix.scr 2.0.2.
>>>>> I've set a component with this annotation:
>>>>>
>>>>>    @Component(enabled = true, configurationPolicy =
>>>>>    ConfigurationPolicy.REQUIRE,
>>>>>             scope = ServiceScope.PROTOTYPE, service =
>>>>>    FixedControllerService.class,
>>>>>             configurationPid = {SERVICE_FACTORY_PID_CONTROLLER})
>>>>>
>>>>>    <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
>>>>>    name="com.c4biz.feast.ComponentControllerServiceProvider"
>>>>>    configuration-policy="require" enabled="true" activate="activate"
>>>>>    deactivate="deactivate" modified="modified"
>>>>>    configuration-pid="fixed.controller">
>>>>>       <implementation
>>>>> class="com.c4biz.feast.ComponentControllerServiceProvider"/>
>>>>>       <service scope="prototype">
>>>>>         <provide interface="com.c4biz.feast.FixedControllerService"/>
>>>>>       </service>
>>>>>    </scr:component>
>>>>>
>>>>> In this component class I have a method (activate()) tagged with @Activate annotation. And there are any reference bind being used for now.
>>>>>
>>>>>  From another bundle I'm creating a configuration using factoryPID = SERVICE_FACTORY_PID_CONTROLLER.
>>>>> Interesting is that the service are being created and with in a proper autogenerated PID and passed properties. At least I can see it when listing the services using gogo console.
>>>>>
>>>>> also scr:list tells me that the component is enabled and satisfied.
>>>>>
>>>>> What I'm not understanding is that the activate method is not being called...
>>>>>
>>>>> could someone explain me what am I missing here?
>>>>>
>>>>> thanks,
>>>>>
>>>>> Cristiano
>>>> ---------------------------------------------------------------------
>>>> 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 <ma...@felix.apache.org>
>> For additional commands, e-mail: users-help@felix.apache.org <ma...@felix.apache.org>


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


Re: doubt about component DS 1.3 with scope Prototype and ConfigurationPolicy.REQUIRE

Posted by David Jencks <da...@yahoo.com.INVALID>.
I’m not sure I’m receiving all your replies….

Most of the things you can specify for a DS component are completely independent, which makes it very powerful, but there are a couple that aren’t and that can be confusing.

It’s unusual to need to specify enabled=false. I don’t think I ever have.  It might be useful if some other component needs to set up an environment without which the disabled component doesn’t make sense.

Configuration policy and scope are independent.  Configuration policy is also somewhat confusing since whether you get one instance or many is determined by config admin, not DS.

For instance if you are using a factory pid in config admin, you can get as many component configurations as you want, one for each configuration.  For each of those, the scope determines how many instances the configuration might have.  Singleton scope means you get at most one, and all requestors get the same service instance.  This is the only scope that is compatible with immediate.  Bundle scope means all requestors from the same bundle get the same instance, and requestors from different bundles get different instances.  Prototype scope means if you use the ServiceObjects interface you can get as many instances as you want.

There’s also stuff you can now do with multiple pids but maybe the above is enough for now….

hope this helps
david jencks

> On Jun 27, 2016, at 3:32 PM, Cristiano Gavião <cv...@gmail.com> wrote:
> 
> Sorry, my mistake...
> 
> only now I understood what you have said about enable=true be the default value... :-[
> 
> On 27/06/2016 19:16, Cristiano Gavião wrote:
>> 
>> 
>> On 27/06/2016 18:48, David Jencks wrote:
>>> You’ve specified prototype scope, so there is never going to be “ONE” canonical instance.  You need something to request the service from the service reference or from the ServiceObjects interface from the service reference.
>>> 
>>> With the default scope, you aren’t going to get an instance created without a user either unless you specify immediate=true as well.
>> if I understood the spec right, when I use immediate=true then I get a Singleton scope, right?
>> 
>> Would a component with scope singleton use ConfigurationPolicy.REQUIRE ?
>> 
>>> 
>>> I generally don’t specify enabled=true since that is the default value.
>> then you let your components as enabled=false and then will use a master component to enable the others ?
>> 
>>> 
>>> david jencks
>>> 
>>>> On Jun 27, 2016, at 2:42 PM, Cristiano Gavião <cv...@gmail.com> wrote:
>>>> 
>>>> Hello,
>>>> 
>>>> I'm facing a situation that I'm not understanding. I'm using org.apache.felix.scr 2.0.2.
>>>> I've set a component with this annotation:
>>>> 
>>>>   @Component(enabled = true, configurationPolicy =
>>>>   ConfigurationPolicy.REQUIRE,
>>>>            scope = ServiceScope.PROTOTYPE, service =
>>>>   FixedControllerService.class,
>>>>            configurationPid = {SERVICE_FACTORY_PID_CONTROLLER})
>>>> 
>>>>   <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
>>>>   name="com.c4biz.feast.ComponentControllerServiceProvider"
>>>>   configuration-policy="require" enabled="true" activate="activate"
>>>>   deactivate="deactivate" modified="modified"
>>>>   configuration-pid="fixed.controller">
>>>>      <implementation
>>>> class="com.c4biz.feast.ComponentControllerServiceProvider"/>
>>>>      <service scope="prototype">
>>>>        <provide interface="com.c4biz.feast.FixedControllerService"/>
>>>>      </service>
>>>>   </scr:component>
>>>> 
>>>> In this component class I have a method (activate()) tagged with @Activate annotation. And there are any reference bind being used for now.
>>>> 
>>>> From another bundle I'm creating a configuration using factoryPID = SERVICE_FACTORY_PID_CONTROLLER.
>>>> Interesting is that the service are being created and with in a proper autogenerated PID and passed properties. At least I can see it when listing the services using gogo console.
>>>> 
>>>> also scr:list tells me that the component is enabled and satisfied.
>>>> 
>>>> What I'm not understanding is that the activate method is not being called...
>>>> 
>>>> could someone explain me what am I missing here?
>>>> 
>>>> thanks,
>>>> 
>>>> Cristiano
>>> 
>>> ---------------------------------------------------------------------
>>> 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 <ma...@felix.apache.org>
> For additional commands, e-mail: users-help@felix.apache.org <ma...@felix.apache.org>

Re: doubt about component DS 1.3 with scope Prototype and ConfigurationPolicy.REQUIRE

Posted by Cristiano Gavião <cv...@gmail.com>.
Sorry, my mistake...

only now I understood what you have said about enable=true be the 
default value... :-[

On 27/06/2016 19:16, Cristiano Gavi�o wrote:
>
>
> On 27/06/2016 18:48, David Jencks wrote:
>> You\u2019ve specified prototype scope, so there is never going to be \u201cONE\u201d 
>> canonical instance.  You need something to request the service from 
>> the service reference or from the ServiceObjects interface from the 
>> service reference.
>>
>> With the default scope, you aren\u2019t going to get an instance created 
>> without a user either unless you specify immediate=true as well.
> if I understood the spec right, when I use immediate=true then I get a 
> Singleton scope, right?
>
> Would a component with scope singleton use ConfigurationPolicy.REQUIRE ?
>
>>
>> I generally don\u2019t specify enabled=true since that is the default value.
> then you let your components as enabled=false and then will use a 
> master component to enable the others ?
>
>>
>> david jencks
>>
>>> On Jun 27, 2016, at 2:42 PM, Cristiano Gavi�o <cv...@gmail.com> 
>>> wrote:
>>>
>>> Hello,
>>>
>>> I'm facing a situation that I'm not understanding. I'm using 
>>> org.apache.felix.scr 2.0.2.
>>> I've set a component with this annotation:
>>>
>>>    @Component(enabled = true, configurationPolicy =
>>>    ConfigurationPolicy.REQUIRE,
>>>             scope = ServiceScope.PROTOTYPE, service =
>>>    FixedControllerService.class,
>>>             configurationPid = {SERVICE_FACTORY_PID_CONTROLLER})
>>>
>>>    <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
>>>    name="com.c4biz.feast.ComponentControllerServiceProvider"
>>>    configuration-policy="require" enabled="true" activate="activate"
>>>    deactivate="deactivate" modified="modified"
>>>    configuration-pid="fixed.controller">
>>>       <implementation
>>> class="com.c4biz.feast.ComponentControllerServiceProvider"/>
>>>       <service scope="prototype">
>>>         <provide interface="com.c4biz.feast.FixedControllerService"/>
>>>       </service>
>>>    </scr:component>
>>>
>>> In this component class I have a method (activate()) tagged with 
>>> @Activate annotation. And there are any reference bind being used 
>>> for now.
>>>
>>>  From another bundle I'm creating a configuration using factoryPID = 
>>> SERVICE_FACTORY_PID_CONTROLLER.
>>> Interesting is that the service are being created and with in a 
>>> proper autogenerated PID and passed properties. At least I can see 
>>> it when listing the services using gogo console.
>>>
>>> also scr:list tells me that the component is enabled and satisfied.
>>>
>>> What I'm not understanding is that the activate method is not being 
>>> called...
>>>
>>> could someone explain me what am I missing here?
>>>
>>> thanks,
>>>
>>> Cristiano
>>
>> ---------------------------------------------------------------------
>> 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: doubt about component DS 1.3 with scope Prototype and ConfigurationPolicy.REQUIRE

Posted by Cristiano Gavião <cv...@gmail.com>.

On 27/06/2016 18:48, David Jencks wrote:
> You\u2019ve specified prototype scope, so there is never going to be \u201cONE\u201d canonical instance.  You need something to request the service from the service reference or from the ServiceObjects interface from the service reference.
>
> With the default scope, you aren\u2019t going to get an instance created without a user either unless you specify immediate=true as well.
if I understood the spec right, when I use immediate=true then I get a 
Singleton scope, right?

Would a component with scope singleton use ConfigurationPolicy.REQUIRE ?

>
> I generally don\u2019t specify enabled=true since that is the default value.
then you let your components as enabled=false and then will use a master 
component to enable the others ?

>
> david jencks
>
>> On Jun 27, 2016, at 2:42 PM, Cristiano Gavi�o <cv...@gmail.com> wrote:
>>
>> Hello,
>>
>> I'm facing a situation that I'm not understanding. I'm using org.apache.felix.scr 2.0.2.
>> I've set a component with this annotation:
>>
>>    @Component(enabled = true, configurationPolicy =
>>    ConfigurationPolicy.REQUIRE,
>>             scope = ServiceScope.PROTOTYPE, service =
>>    FixedControllerService.class,
>>             configurationPid = {SERVICE_FACTORY_PID_CONTROLLER})
>>
>>    <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
>>    name="com.c4biz.feast.ComponentControllerServiceProvider"
>>    configuration-policy="require" enabled="true" activate="activate"
>>    deactivate="deactivate" modified="modified"
>>    configuration-pid="fixed.controller">
>>       <implementation
>>    class="com.c4biz.feast.ComponentControllerServiceProvider"/>
>>       <service scope="prototype">
>>         <provide interface="com.c4biz.feast.FixedControllerService"/>
>>       </service>
>>    </scr:component>
>>
>> In this component class I have a method (activate()) tagged with @Activate annotation. And there are any reference bind being used for now.
>>
>>  From another bundle I'm creating a configuration using factoryPID = SERVICE_FACTORY_PID_CONTROLLER.
>> Interesting is that the service are being created and with in a proper autogenerated PID and passed properties. At least I can see it when listing the services using gogo console.
>>
>> also scr:list tells me that the component is enabled and satisfied.
>>
>> What I'm not understanding is that the activate method is not being called...
>>
>> could someone explain me what am I missing here?
>>
>> thanks,
>>
>> Cristiano
>
> ---------------------------------------------------------------------
> 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: doubt about component DS 1.3 with scope Prototype and ConfigurationPolicy.REQUIRE

Posted by David Jencks <da...@yahoo.com.INVALID>.
You’ve specified prototype scope, so there is never going to be “ONE” canonical instance.  You need something to request the service from the service reference or from the ServiceObjects interface from the service reference.

With the default scope, you aren’t going to get an instance created without a user either unless you specify immediate=true as well.

I generally don’t specify enabled=true since that is the default value.

david jencks

> On Jun 27, 2016, at 2:42 PM, Cristiano Gavião <cv...@gmail.com> wrote:
> 
> Hello,
> 
> I'm facing a situation that I'm not understanding. I'm using org.apache.felix.scr 2.0.2.
> I've set a component with this annotation:
> 
>   @Component(enabled = true, configurationPolicy =
>   ConfigurationPolicy.REQUIRE,
>            scope = ServiceScope.PROTOTYPE, service =
>   FixedControllerService.class,
>            configurationPid = {SERVICE_FACTORY_PID_CONTROLLER})
> 
>   <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
>   name="com.c4biz.feast.ComponentControllerServiceProvider"
>   configuration-policy="require" enabled="true" activate="activate"
>   deactivate="deactivate" modified="modified"
>   configuration-pid="fixed.controller">
>      <implementation
>   class="com.c4biz.feast.ComponentControllerServiceProvider"/>
>      <service scope="prototype">
>        <provide interface="com.c4biz.feast.FixedControllerService"/>
>      </service>
>   </scr:component>
> 
> In this component class I have a method (activate()) tagged with @Activate annotation. And there are any reference bind being used for now.
> 
> From another bundle I'm creating a configuration using factoryPID = SERVICE_FACTORY_PID_CONTROLLER.
> Interesting is that the service are being created and with in a proper autogenerated PID and passed properties. At least I can see it when listing the services using gogo console.
> 
> also scr:list tells me that the component is enabled and satisfied.
> 
> What I'm not understanding is that the activate method is not being called...
> 
> could someone explain me what am I missing here?
> 
> thanks,
> 
> Cristiano


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