You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Jean-Philippe Clement <je...@sogeti.com> on 2010/07/20 16:08:00 UTC

Karaf blueprint reference-list unbind-method sends null

Hello, I'm using Karaf 1.6.0. A blueprint bundle declares something like:
	<reference-list interface="..." availability="optional">
		<reference-listener ref="SomeRef" bind-method="addStuff"  
unbind-method="removeStuff" />
	</reference-list>

When starting the bundle, SomeRef.removeStuff() is called with a null  
reference.

I use reference lists without problems, but this time the unbind  
method is called with a null reference when the bundle is started.

Can anybody tell me why do I get a null reference and what is the  
meaning of this null?

Thanks.


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


Re: Karaf blueprint reference-list unbind-method sends null

Posted by Guillaume Nodet <gn...@gmail.com>.
On Tue, Jul 20, 2010 at 17:42, Jean-Philippe Clement
<je...@sogeti.com> wrote:
>
>
>  So the null value would mean "no service to register on startup".

Exactly.

>  Is it an expected (spec compliant) behavior or a "bug"?

It's explicitly stated in section 121.7.12 of the Enterprise spec.

>
>  PS: How to avoid null other than adding "if (ref!=null)" in the code?

I guess that's the way to go ;-)

>  Quoting Guillaume Nodet <gn...@gmail.com>:
>
>> I think when a reference (list or not) is created, the listeners have
>> to be called.  So if there is a matching service in the osgi registry,
>> the listener bind method will be called (once for an unary reference
>> or once for each object in the list), but if there's no matching
>> service, the unbind method will be called.
>> This is to make sure your listener is updated wrt to the current state
>> when starting.
>>
>> On Tue, Jul 20, 2010 at 16:08, Jean-Philippe Clement
>> <je...@sogeti.com> wrote:
>>>
>>> Hello, I'm using Karaf 1.6.0. A blueprint bundle declares something like:
>>>        <reference-list interface="..." availability="optional">
>>>                <reference-listener ref="SomeRef" bind-method="addStuff"
>>> unbind-method="removeStuff" />
>>>        </reference-list>
>>>
>>> When starting the bundle, SomeRef.removeStuff() is called with a null
>>> reference.
>>>
>>> I use reference lists without problems, but this time the unbind method
>>> is
>>> called with a null reference when the bundle is started.
>>>
>>> Can anybody tell me why do I get a null reference and what is the meaning
>>> of
>>> this null?
>>>
>>> Thanks.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>>
>>>
>>
>>
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://fusesource.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

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


Re: Karaf blueprint reference-list unbind-method sends null

Posted by Jean-Philippe Clement <je...@sogeti.com>.

   So the null value would mean "no service to register on startup".

   Is it an expected (spec compliant) behavior or a "bug"?

   PS: How to avoid null other than adding "if (ref!=null)" in the code?

   Quoting Guillaume Nodet <gn...@gmail.com>:

> I think when a reference (list or not) is created, the listeners have
> to be called.  So if there is a matching service in the osgi registry,
> the listener bind method will be called (once for an unary reference
> or once for each object in the list), but if there's no matching
> service, the unbind method will be called.
> This is to make sure your listener is updated wrt to the current state
> when starting.
>
> On Tue, Jul 20, 2010 at 16:08, Jean-Philippe Clement
> <je...@sogeti.com> wrote:
>> Hello, I'm using Karaf 1.6.0. A blueprint bundle declares something like:
>>        <reference-list interface="..." availability="optional">
>>                <reference-listener ref="SomeRef" bind-method="addStuff"
>> unbind-method="removeStuff" />
>>        </reference-list>
>>
>> When starting the bundle, SomeRef.removeStuff() is called with a null
>> reference.
>>
>> I use reference lists without problems, but this time the unbind method is
>> called with a null reference when the bundle is started.
>>
>> Can anybody tell me why do I get a null reference and what is the meaning of
>> this null?
>>
>> Thanks.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>



Re: Karaf blueprint reference-list unbind-method sends null

Posted by Guillaume Nodet <gn...@gmail.com>.
I think when a reference (list or not) is created, the listeners have
to be called.  So if there is a matching service in the osgi registry,
the listener bind method will be called (once for an unary reference
or once for each object in the list), but if there's no matching
service, the unbind method will be called.
This is to make sure your listener is updated wrt to the current state
when starting.

On Tue, Jul 20, 2010 at 16:08, Jean-Philippe Clement
<je...@sogeti.com> wrote:
> Hello, I'm using Karaf 1.6.0. A blueprint bundle declares something like:
>        <reference-list interface="..." availability="optional">
>                <reference-listener ref="SomeRef" bind-method="addStuff"
> unbind-method="removeStuff" />
>        </reference-list>
>
> When starting the bundle, SomeRef.removeStuff() is called with a null
> reference.
>
> I use reference lists without problems, but this time the unbind method is
> called with a null reference when the bundle is started.
>
> Can anybody tell me why do I get a null reference and what is the meaning of
> this null?
>
> Thanks.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

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