You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by Holly Cummins <cu...@uk.ibm.com> on 2011/05/08 13:55:48 UTC
Reference listeners and null reference lists
Hi all,
I'm hitting a problem with reference listeners which feels like a mini-bug
to me, but I thought I'd see what everyone else thinks. I've got a bean
with a blueprint-injected reference list. The same bean also has a
reference listener. When the system is initializing, the bind() method is
called before the reference list has been injected.
The specification says: "For reference-list callbacks, the service proxy
is guaranteed to be available in the collection before a bind callback
is invoked, and to remain in the collection until after an unbind callback
has completed."
The specification doesn't actually say that anyone has to have been told
about the collection which is being modified, so technically our behaviour
is within the letter of the spec. However, it feels like the *intention*
of the specification is that if the bind() method is called consumers of
the service should have access to a collection which accurately represents
the final state of the reference list.
On the other hand, relying on the system being in a particularly
consistent state during initialisation is obviously unwise, and against
the more general spirit of OSGi dynamism, so maybe what we're doing is
perfectly reasonable!
What do people think?
The code I'm using is:
<bean id="thingAggregator" class="...">
<property name="things" ref="thinglist" />
</bean>
<reference-list
id="thinglist"
interface="Thing">
<reference-listener
ref="thingAggregator"
bind-method="bind"/>
</reference-list>
public void bind(Thing thing) {
System.out.println("DEBUG: bind called, things is " +
things);
}
Regards,
Holly
--
Holly Cummins
IBM Hursley, UK
cumminsh@uk.ibm.com
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number
741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
Re: Reference listeners and null reference lists
Posted by Mark Nuttall <mn...@apache.org>.
Hi Holly,
This sounds like a bug. I agree that "For reference-list callbacks, the
service proxy is guaranteed to be available in the collection before a bind
callback is invoked" strongly suggests that the new reference should have
been injected before bind() was called.
Regards,
Mark
On 8 May 2011 13:55, Holly Cummins <cu...@uk.ibm.com> wrote:
> Hi all,
>
> I'm hitting a problem with reference listeners which feels like a mini-bug
> to me, but I thought I'd see what everyone else thinks. I've got a bean with
> a blueprint-injected reference list. The same bean also has a reference
> listener. When the system is initializing, the bind() method is called
> before the reference list has been injected.
>
> The specification says: "For reference-list callbacks, the service proxy is
> guaranteed to be available in the collection before a bind callback
> is invoked, and to remain in the collection until after an unbind callback
> has completed."
>
> The specification doesn't actually say that anyone has to have been told
> about the collection which is being modified, so technically our behaviour
> is within the letter of the spec. However, it feels like the *intention* of
> the specification is that if the bind() method is called consumers of the
> service should have access to a collection which accurately represents the
> final state of the reference list.
>
> On the other hand, relying on the system being in a particularly consistent
> state during initialisation is obviously unwise, and against the more
> general spirit of OSGi dynamism, so maybe what we're doing is perfectly
> reasonable!
>
> What do people think?
>
> The code I'm using is:
>
> <bean id=*"thingAggregator" *class=*"..."*>
> <property name=*"things"* ref=*"thinglist"* />
> </bean>
>
> <reference-list
> id=*"thinglist"*
> interface=*"Thing"*>
> <reference-listener
> ref=*"thingAggregator"*
> bind-method=*"bind"*/>
> </reference-list>
>
>
> *public* *void* bind(Thing thing) {
> System.out.println("DEBUG: bind called, things is " +
> things);
> }
>
>
> Regards,
> Holly
>
> --
> Holly Cummins
> IBM Hursley, UK
> cumminsh@uk.ibm.com
>
>
>
> ------------------------------
>
> *
> *
>
> *Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number
> 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
> *
>
>
>
>
>
>
>