You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Andrei Pozolotin (JIRA)" <ji...@apache.org> on 2011/05/20 19:59:47 UTC

[jira] [Created] (FELIX-2961) SCR & ConfigurationAdmin : service.pid resolution

SCR & ConfigurationAdmin : service.pid resolution
-------------------------------------------------

                 Key: FELIX-2961
                 URL: https://issues.apache.org/jira/browse/FELIX-2961
             Project: Felix
          Issue Type: Bug
          Components: Declarative Services (SCR)
    Affects Versions:  scr-1.6.0
            Reporter: Andrei Pozolotin


hello!

when I use config admin to control instaniation of scr component services, I use this pattern:


// 1) in config source bundle:
			Configuration config = configAdmin.getConfiguration("ZZZ", null);
			Dictionary<String, String> props = config.getProperties();
			config.update(props);


//  2) in config target bundle:
@Service
@Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
public class BucketPlugin implements PluginSpaceService {

	@Property(name = "service.pid")
	protected static final String PID = "ZZZ";


// 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
    <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
        <implementation class="com.ddfplus.core.space.BucketPlugin"/>
        <service servicefactory="false">
            <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
        </service>
        <property name="service.pid" type="String" value="ZZZ"/>


// 4) the scr fails to initialize the component; intitialzation works only when 
(scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)


// 5) if I look on the the config target in console (when I do manage to inititialize it),
it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid


thank you.


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (FELIX-2961) SCR & ConfigurationAdmin : service.pid resolution

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13037869#comment-13037869 ] 

Felix Meschberger commented on FELIX-2961:
------------------------------------------

Actually I disagree (even after reading the mail thread again).

The spec states that the Component Name is to be used to get the applicable configuration from Configuration Admin. In you sample this would be "AAA" and not your Service PID value of "ZZZ". Hence the code works as designed and the configuration required is for "AAA". See Section 112.7, Deployment, of the Declarative Services specification.

Actually, IIRC as a consequence of the thread you refer to, the SCR plugin automatically sets the service.pid property in the component descriptor unless the component already sets this property itself.

> SCR & ConfigurationAdmin : service.pid resolution
> -------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (FELIX-2961) @Component annotation should support defining the name with a compile time constant (instead of just a constant value)

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler updated FELIX-2961:
------------------------------------

    Component/s:     (was: Declarative Services (SCR))
                 Maven SCR Plugin

> @Component annotation should support defining the name with a compile time constant (instead of just a constant value)
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: New Feature
>          Components: Maven SCR Plugin
>    Affects Versions: scr annotations 1.5.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-2961) SCR & ConfigurationAdmin : service.pid resolution

Posted by "Andrei Pozolotin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13044556#comment-13044556 ] 

Andrei Pozolotin commented on FELIX-2961:
-----------------------------------------

Felix: 

this is a test case:
https://github.com/carrot-garden/carrot-bugger/tree/master/carrot-bug-FELIX-2961-001
https://github.com/carrot-garden/carrot-bugger/blob/master/carrot-bug-FELIX-2961-001/src/main/java/bench/TestComponent.java

which magically produces valid xml, with a non-compile-time property:
https://github.com/carrot-garden/carrot-bugger/blob/master/carrot-bug-FELIX-2961-001/example/serviceComponents.xml

I would like to reuse same magic for @Copmonent(name), via @Property(value="component.name");

steps to reproduce:
https://github.com/carrot-garden/carrot-bugger/blob/master/carrot-bug-FELIX-2961-001/launch/reproduce.sh

thanks again,

Andrei.



> SCR & ConfigurationAdmin : service.pid resolution
> -------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (FELIX-2961) SCR & ConfigurationAdmin : service.pid resolution

Posted by "Andrei Pozolotin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13036967#comment-13036967 ] 

Andrei Pozolotin commented on FELIX-2961:
-----------------------------------------

the motivation for this fix is that java annotations allow only for compile time constans, 
and I can not use a construct like this:

// on service interface:
public interface PluginSpaceService {
	String PID = PluginSpaceService.class.getName();


// on target comonent:
@Component(name = PluginSpaceService.PID)
public class BucketPlugin implements PluginSpaceService {





> SCR & ConfigurationAdmin : service.pid resolution
> -------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (FELIX-2961) SCR & ConfigurationAdmin : service.pid resolution

Posted by "Andrei Pozolotin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13038584#comment-13038584 ] 

Andrei Pozolotin commented on FELIX-2961:
-----------------------------------------

how about this approach:

the scr anntotation parser could do this:

1) if normal attribute

   @Component(name = "some compile-time constant") 

is present - use it for compenent name

2) if not, but property attribute

   @Property(name = "component.name")
   protected static final String NAME = "some NON-comple time constant that produces actual component name"; 

is present - use it for compenent name instead
(surprisingly, this currently works fine in scr parser, despite "dog biting its own tail")

as you can see, I really do not want to manually manage still another namespace :-) !


> SCR & ConfigurationAdmin : service.pid resolution
> -------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (FELIX-2961) SCR & ConfigurationAdmin : service.pid resolution

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13038426#comment-13038426 ] 

Felix Meschberger commented on FELIX-2961:
------------------------------------------

No the component name is set as the name attribute of the <component> element. And this is fixed and static XML and is read unmodified. So there is no way to set this dynamically with configuration ... this would be like a dog biting its own tail ;-)

In addition, please think twice before making service PIDs configurable. The PID is an identifiaction of the service and as such should be modifiable at will....

> SCR & ConfigurationAdmin : service.pid resolution
> -------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (FELIX-2961) SCR & ConfigurationAdmin : service.pid resolution

Posted by "Andrei Pozolotin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13037227#comment-13037227 ] 

Andrei Pozolotin commented on FELIX-2961:
-----------------------------------------

this thread seems to confirm that my expectations of how it is supposed to work are correct:

Felix Meschberger 	Declarative Services and service.pid 	Wed, 05 Sep, 13:08
Carsten Ziegeler 	  Re: Declarative Services and service.pid 	Wed, 05 Sep, 14:05
Felix Meschberger 	    Re: Declarative Services and service.pid 	Wed, 05 Sep, 14:23
Carsten Ziegeler 	      Re: Declarative Services and service.pid 	Wed, 05 Sep, 14:31
Felix Meschberger 	        Re: Declarative Services and service.pid 	Wed, 05 Sep, 14:49
Carsten Ziegeler 	          Re: Declarative Services and service.pid 	Wed, 05 Sep, 15:15
Felix Meschberger 	            Re: Declarative Services and service.pid 	Wed, 05 Sep, 18:03
Niclas Hedhman 	  Re: Declarative Services and service.pid 	Thu, 06 Sep, 03:53
Felix Meschberger 	    Re: Declarative Services and service.pid 	Thu, 06 Sep, 06:22
Niclas Hedhman 	      Re: Declarative Services and service.pid 	Thu, 06 Sep, 11:12

http://mail-archives.apache.org/mod_mbox/felix-dev/200709.mbox/%3C1188997693.3542.20.camel@bslm-046.corp.day.com%3E


> SCR & ConfigurationAdmin : service.pid resolution
> -------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (FELIX-2961) @Component annotation should support defining the name with a compile time constant (instead of just a constant value)

Posted by "Andrei Pozolotin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13046588#comment-13046588 ] 

Andrei Pozolotin commented on FELIX-2961:
-----------------------------------------

same request applies to class-level @Property:

in this snippet:

@Component
@Property( name = EventConstants.EVENT_TOPIC, value = { EventAPI.OPEN, EventAPI.CLOSED } )
public class TestCentralLoginResponse {

again, value = { EventAPI.OPEN, EventAPI.CLOSED ) must be a compile-time constant, which is no good.


> @Component annotation should support defining the name with a compile time constant (instead of just a constant value)
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: New Feature
>          Components: Declarative Services (SCR)
>    Affects Versions: scr annotations 1.5.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (FELIX-2961) SCR & ConfigurationAdmin : service.pid resolution

Posted by "Andrei Pozolotin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13037970#comment-13037970 ] 

Andrei Pozolotin commented on FELIX-2961:
-----------------------------------------

Felix: thanks for looking into this.

re: "unless the component already sets this property itself. "

this is how I set this property myself:

@Property(name = "service.pid")
protected static final String PID = "ZZZ"; 

and it is confirmed by generated xml:

        <property name="service.pid" type="String" value="ZZZ"/> 

hence my suggestion is simple: 
for SCR runtime NOT to ignore property name="service.pid"
if it is present in xml.

and if it is missing (not set), your logic above is unchanged.

Andrei.


> SCR & ConfigurationAdmin : service.pid resolution
> -------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (FELIX-2961) SCR & ConfigurationAdmin : service.pid resolution

Posted by "Andrei Pozolotin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13037980#comment-13037980 ] 

Andrei Pozolotin commented on FELIX-2961:
-----------------------------------------

in other words, my interpretation of 112.7:

"The name of the component is used as the key for obtaining additional com-
ponent properties from Configuration Admin."

"name of the component" => really means :-)

if "service.pid" is present, then use it;
if "service.pid" is missing, set "service.pid"="name of the component"
finally, use "service.pid" as the key for Configuration Admin


> SCR & ConfigurationAdmin : service.pid resolution
> -------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (FELIX-2961) SCR & ConfigurationAdmin : service.pid resolution

Posted by "Andrei Pozolotin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13038240#comment-13038240 ] 

Andrei Pozolotin commented on FELIX-2961:
-----------------------------------------

Felix:

since the "pid vs name problem" is decided;

I have only "small one" left: do you think there is a way SCR plugin could accept "component name"

// on target comonent:
@Component(name = PluginSpaceService.PID)
public class BucketPlugin implements PluginSpaceService { 

in such a way that it does not have to be a compile-time constant (required by annotation)?

say, similar to how you handle same problem for @Property

@Property(name = "service.pid")
protected static final String PID = "ZZZ"; 

thank you

Andrei


> SCR & ConfigurationAdmin : service.pid resolution
> -------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (FELIX-2961) SCR & ConfigurationAdmin : service.pid resolution

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13041085#comment-13041085 ] 

Felix Meschberger commented on FELIX-2961:
------------------------------------------

What exactly do you have in mind for option 2 ? As it stands, it is a compile-time constant (actually ending in the constant pool section of the class).

But then you should anyway be able to do this:

  @Component(name=TheClass.SOME_NAME_FIELD)
  class TheClass {
      private static final String SOME_NAME_FIELD="some constant";
  }

Right ?

> SCR & ConfigurationAdmin : service.pid resolution
> -------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (FELIX-2961) @Component annotation should support defining the name with a compile time constant (instead of just a constant value)

Posted by "Andrei Pozolotin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13046319#comment-13046319 ] 

Andrei Pozolotin commented on FELIX-2961:
-----------------------------------------

re: "new feature of the @Component annotation". 
yes, thank you.

re: "this property will always be overwritten". 
well, the alternative interpretation would be:
if there is no "name" attribute provided for the @Component(...) ,
and a property with the name "component.name" is provided instead,
then use the "component.name" property value for the xml tag attribute;

> @Component annotation should support defining the name with a compile time constant (instead of just a constant value)
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: New Feature
>          Components: Declarative Services (SCR)
>    Affects Versions: scr annotations 1.5.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (FELIX-2961) SCR & ConfigurationAdmin : service.pid resolution

Posted by "Andrei Pozolotin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13038233#comment-13038233 ] 

Andrei Pozolotin commented on FELIX-2961:
-----------------------------------------

the osgi oracle spoke: (posted with his permission):

################################################

I am afraid I agree with Felix Meschberger. Any properties registered in the XML should not be interpreted. Setting the service.pid has no meaning (unless you provide the Managed Service (Factory)) interface. SCR does not use MS(F)s, it uses Configuration Listener.

So PID == component name.

If you still disagree, please file a bug on the public OSGi Bugzilla, it will then be discussed in CPEG.

Kind regards,

	Peter Kriens

On 23 mei 2011, at 16:59, Andrei Pozolotin wrote:
> >    *Peter, hello;*
> > 
> >    Do you think you could shed some light here:
> >    https://issues.apache.org/jira/browse/FELIX-2961
> >    SCR & ConfigurationAdmin : service.pid resolution
> > 
> >    Please  :-) 
> > 
> >    Thank you,
> > 
> >    Andrei
> > 
> > 
################################################

> SCR & ConfigurationAdmin : service.pid resolution
> -------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (FELIX-2961) @Component annotation should support defining the name with a compile time constant (instead of just a constant value)

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger updated FELIX-2961:
-------------------------------------

    Affects Version/s:     (was:  scr-1.6.0)
                       scr annotations 1.5.0
           Issue Type: New Feature  (was: Bug)
              Summary: @Component annotation should support defining the name with a compile time constant (instead of just a constant value)  (was: SCR & ConfigurationAdmin : service.pid resolution)

Hmm, I see.

First of all: Thanks for the elaborate test case ! This makes it really easy to follow up with what you have in mind.

Ok, a comment first: I think we should really log a warning (if not breaking on error) if a property with the name "component.name" is being defined. The reason is that this property will always be overwritten by the actual component name and thus may never be provided by the developer.

Now, I think this is really a request for a new feature of the @Component annotation. Thus changing the issue type, affected versions and summary.

> @Component annotation should support defining the name with a compile time constant (instead of just a constant value)
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: FELIX-2961
>                 URL: https://issues.apache.org/jira/browse/FELIX-2961
>             Project: Felix
>          Issue Type: New Feature
>          Components: Declarative Services (SCR)
>    Affects Versions: scr annotations 1.5.0
>            Reporter: Andrei Pozolotin
>
> hello!
> when I use config admin to control instaniation of scr component services, I use this pattern:
> // 1) in config source bundle:
> 			Configuration config = configAdmin.getConfiguration("ZZZ", null);
> 			Dictionary<String, String> props = config.getProperties();
> 			config.update(props);
> //  2) in config target bundle:
> @Service
> @Component(name = "AAA", policy = ConfigurationPolicy.REQUIRE, immediate = true)
> public class BucketPlugin implements PluginSpaceService {
> 	@Property(name = "service.pid")
> 	protected static final String PID = "ZZZ";
> // 3) despite the fact service.pid "looks good" in xml for the tagret compenent:
>     <scr:component enabled="true" immediate="true" name="AAA" configuration-policy="require">
>         <implementation class="com.ddfplus.core.space.BucketPlugin"/>
>         <service servicefactory="false">
>             <provide interface="com.ddfplus.api.plugin.PluginSpaceService"/>
>         </service>
>         <property name="service.pid" type="String" value="ZZZ"/>
> // 4) the scr fails to initialize the component; intitialzation works only when 
> (scr.component.name == config.service.pid) and NOT when (config.service.pid == scr.component.property.pid)
> // 5) if I look on the the config target in console (when I do manage to inititialize it),
> it shows that again, actual service.pid comes from scr.component.name and not from scr.component.property.service.pid
> thank you.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira