osgi:list with a listener to a bean with prototype scope [message #1008570] |
Wed, 13 February 2013 00:59  |
Eclipse User |
|
|
|
Hi, is the below scenario possible?
<osgi:list cardinality="0..N" id="list" interface="Service">
<osgi:listener ref="prototypeBean" bind-method="registerService" unbind-method="deregisterService"></osgi:listener>
</osgi:list>
<bean id="prototypeBean" class="SomeBeanClass" scope="prototype"></bean>
With this code, a new prototypeBean is instantiated at context load time and its listener methods are called when list changes. However, new prototypeBeans do not receive the callbacks.
Is it possible instead that the listener methods are called on new instances of prototypeBean (and ideally that no prototypeBean is instantiated at context load time).
Thanks, Dan.
|
|
|
|
Re: osgi:list with a listener to a bean with prototype scope [message #1112487 is a reply to message #1107258] |
Thu, 19 September 2013 15:41  |
Eclipse User |
|
|
|
I think that this is not the Idea.
If the bean is prototype, it will be created when the service list needs. The list will not track new instances of this Bean to notify.
If its the Idea, I recommend that you create some kind of service tracker (not necessarily an OSGi service tracker).
This tracker will be linked on tracked services, and can have listeners to notify they lifecicle.
So, you can Inject this tracker in your prototype bean, and register itself to listen about an specific service.
Hope that helps.
|
|
|
Powered by
FUDForum. Page generated in 0.28410 seconds