[
https://issues.apache.org/jira/browse/FELIX-354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12525100
]
Felix Meschberger commented on FELIX-354:
-----------------------------------------
The service.pid property is not set by the SCR. It is either set by the
declared component properties or by the configuration properties of there is
configuration for the component.
But there is some subtlety here: The ConfigurationAdmin.getConfiguration method
always returns a Configuration object - either an existing or a newly created
configuration. In the case of a newly created configuration object, the
configuration apears to exist but as there has not been any properties set and
thus the Configuration.update(Dictionary) method never called, the newly
created object returns null instead of an empty Dictionary.
In short, the component properties will not contain any ConfigurationAdmin
configuration if the respective configuration object does not return a
Dictionary. Therefore, the service.pid is not set. On the other hand, as soon
as the Configuration.update(Dictionary) method has been called and the
configuration data been stored, the component is cycled and provided with the
new configuration data, this time with the service.pid property.
To my understanding, this all works as specified. Still I agree, that it would
probably be good to have the service.pid in the service properties and the
component properties at all time.
Two solutions come to mind:
(1) Enhance SCR to inject the service.pid if not existing. I am not sure,
whether this is ok with the spec
(2) Enhance the maven-scr-plugin to create a service.pid property automatically
Discussing these options in the dev list.
> Service.PID not always available in properties
> ----------------------------------------------
>
> Key: FELIX-354
> URL: https://issues.apache.org/jira/browse/FELIX-354
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services
> Reporter: Carsten Ziegeler
>
> In some cases, the property Constants.SERVICE_PID is null for a service even
> if it has a configuration.
> Use case:
> Two services are registered through SCR, service A has a static reference to
> service B.
> When the bind method in Service A is called with the ServiceReference to B,
> the SERVICE_PID is null in the properties.
> Service B has a configuration and can be configured through the configuration
> admin (SERVICE_PID is available there).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.