You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Tom Watson (Jira)" <ji...@apache.org> on 2023/01/28 14:57:00 UTC

[jira] [Commented] (FELIX-6589) update method with constructor injection does not work

    [ https://issues.apache.org/jira/browse/FELIX-6589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17681591#comment-17681591 ] 

Tom Watson commented on FELIX-6589:
-----------------------------------

Seems a bit strange to specify updates for a static reference.  I would think the component should get deactivated if the static reference to the constructor changes.  Also seems weird to be able to mix method injection with constructor injection with the same reference.  I would go to spec for clarification before investigating anything here.

> update method with constructor injection does not work
> ------------------------------------------------------
>
>                 Key: FELIX-6589
>                 URL: https://issues.apache.org/jira/browse/FELIX-6589
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions: scr-2.2.6
>            Reporter: Jürgen Albert
>            Priority: Major
>
> I have a scenario, where I use constructor injection and on one of the references I get an update method is defined. When the properties of the registered service change the update method is never called however. 
> When I move the Reference from the constructor to a usual bind method, or even with a duplicated on it works like a charm.  
> The Constructor looks as follows:
> {code:java}
> 	public DefaultResourceSetFactoryComponent(ComponentContext ctx,
> 			@Reference(name="resourceFactoryRegistry", unbind="unsetResourceFactoryRegistry", updated = "modifiedResourceFactoryRegistry")
> 			ServiceReference<Resource.Factory.Registry> resourceFactoryRegistryReference
> 			) {
> {code}
> The bind method that works looks as follows:
> {code:java}
> @Reference(policy=ReferencePolicy.STATIC, unbind="unsetResourceFactoryRegistry", updated = "modifiedResourceFactoryRegistry")
> 	public void setResourceFactoryRegistry(Resource.Factory.Registry resourceFactoryRegistry, Map<String, Object> properties) {
> {code}
> Both update methodes are mentioned correctly in the resulting component xml.
> I also played around with ComponentServiceObjects, ServiceReference and the service itself. Result stays the same.
> If the Spec says that this is the correct behavior that I can't fin the passage.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)