You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by Daniel Kuffner <da...@googlemail.com> on 2012/05/17 12:18:16 UTC

Felix SCR Annotations - Reference Binding with Map parameter

Hi All,

I have a question regarding the Felix SCR annotations regarding
bind/unbind references.

The Declarative Services specification defines the following method
signatures for binding methods:
1. void <method-name>(ServiceReference);
2. void <method-name>(<parameter-type>);
3. void <method-name>(<parameter-type>, Map);

I have tried all variants and it seem to be that variant 3 doesn't work.
I get following error message:

@Reference: Missing method setServiceB for reference serviceB
@Reference: Missing method unsetServiceB for reference serviceB

Is that a known limitation or do I miss something.
I use SCR Generator 1.1.4


Here is the example code:

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;

import java.util.Map;

@Component(immediate = true)
public class ReferenceMapProblem {

    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY,
            bind = "setServiceB",
            unbind = "unsetServiceB")
    private IServiceB service;

    protected void setServiceB(IServiceB s, Map map) {
        // ...
    }

    protected void unsetServiceB(IServiceB s, Map map) {
        // ...
    }
}

Re: Felix SCR Annotations - Reference Binding with Map parameter

Posted by Daniel Kuffner <da...@googlemail.com>.
works now,

Thank you
Daniel

Re: Felix SCR Annotations - Reference Binding with Map parameter

Posted by Felix Meschberger <fm...@adobe.com>.
Hi,

Am 17.05.2012 um 12:18 schrieb Daniel Kuffner:

> Hi All,
> 
> I have a question regarding the Felix SCR annotations regarding
> bind/unbind references.
> 
> The Declarative Services specification defines the following method
> signatures for binding methods:
> 1. void <method-name>(ServiceReference);
> 2. void <method-name>(<parameter-type>);
> 3. void <method-name>(<parameter-type>, Map);

Using these signatures requires the component to be declared with the DS V 1.1. namespace. Otherwise the signature is not checked and thus not used.

> 
> I have tried all variants and it seem to be that variant 3 doesn't work.
> I get following error message:
> 
> @Reference: Missing method setServiceB for reference serviceB
> @Reference: Missing method unsetServiceB for reference serviceB
> 
> Is that a known limitation or do I miss something.
> I use SCR Generator 1.1.4
> 
> 
> Here is the example code:
> 
> import org.apache.felix.scr.annotations.Component;
> import org.apache.felix.scr.annotations.Reference;
> import org.apache.felix.scr.annotations.ReferenceCardinality;
> 
> import java.util.Map;
> 
> @Component(immediate = true)

Add specVersion="1.1" to declare the component with the DS v.1.1 namespace.

Regards
Felix


> public class ReferenceMapProblem {
> 
>    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY,
>            bind = "setServiceB",
>            unbind = "unsetServiceB")
>    private IServiceB service;
> 
>    protected void setServiceB(IServiceB s, Map map) {
>        // ...
>    }
> 
>    protected void unsetServiceB(IServiceB s, Map map) {
>        // ...
>    }
> }